regex

Python regex \w* versus \w+

import re
namesRegex = re.compile(r’Agent (\w)w+’)
namesRegex.sub(r’Agent \1****’, ‘Agent Alice gave the secret documents to Agent Bob’)

Why doesn’t this give me Agent A**** gave the secret document to Agent B****.’?
If I use the followin…

Regex to extract the string

I need help with regex to get the following out of the string
dal001.caxxxxx.test.com. —> caxxxxx.test.com
caxxxx.test.com —–> caxxxx.test.com

So basically in the first example, I don’t want dal001 or anything that starts with …

Regex Names which have received a B

I have the folllowing lines
John SMith: A
Pedro Smith: B
Jonathan B: A
John B: B
Luis Diaz: A
Scarlet Diaz: B

I need to get all student names which have received a B.
I tried this but it doesnt work 100%
x = re.findall(r’\b(.*?)\bB’, gra…