+ 1

Does anyone know the problem with this code? It's supposed to replace the Agent names with (Initial)****.

import re agentRegex = re.compile(r'Agent (/w)/w*') mo = agentRegex.sub(r'\1****', 'Agent Alice knew that Agent Bob told Agent Carol that Agent Eve was a double agent.') print(mo)

21st Dec 2016, 1:33 PM
1-up Man
1-up Man - avatar
3 Réponses
+ 1
re is what you import to use regexes (short for regular expressions). It's part of the lessons in the app.
21st Dec 2016, 2:38 PM
1-up Man
1-up Man - avatar
0
sorry but I got a question too, can someone explain what is re 😓 ?
21st Dec 2016, 2:32 PM
A B
0
Wait i fixed it. Its \w, not /w
21st Dec 2016, 2:40 PM
1-up Man
1-up Man - avatar