I didn't want to write and ask this forum but I am stuck and the book I'm following, that supposed to be for beginners, is anything but...
Anyway... In the string below:
'Agent Alice told Agent Bob that Agent Steve was a double agent.'
I want to show just the first letter of the agent's first name. So what I end up with, is:
'Agent A**** told Agent B**** that Agent S**** was a double agent.'
I tried using grouping, like in the book, but its not working.
namesRegex = re.compile(r'\w?([A-Z])')
mo = namesRegex.sub(r'\1****', 'Agent Alice told Agent Bob that Agent
Steve was a double agent.')
print(mo)
Also, I would welcome any recommended additional resources on this topic Thanks in advance...