You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2011-05-14.21:49:39.374>created_at=<Date2011-05-14.15:04:53.100>labels= ['expert-regex']
title='re.sub() replaces only several matches'updated_at=<Date2011-05-14.22:13:00.721>user='https://bugs.python.org/arysin'
When trying to replace strings with parenthesis (in the given example - alternative writing of the words in Ukrainian) the sed replace performs correctly replacing all occurrences, while python3 re.sub() function replaces only first two
mrabarnett commented on May 14, 2011
mrabarnettmannequin
Mannequin
More actions
Argument 4 of re.sub is the maximum number of replacements, NOT flags:
Activity
arysin commentedon May 14, 2011
When trying to replace strings with parenthesis (in the given example - alternative writing of the words in Ukrainian) the sed replace performs correctly replacing all occurrences, while python3 re.sub() function replaces only first two
mrabarnett commentedon May 14, 2011
Argument 4 of re.sub is the maximum number of replacements, NOT flags:
Help on function sub in module re:
re.I is 2, so you're telling it to perform at most 2 replacements.
ezio-melotti commentedon May 14, 2011
See bpo-11957.
arysin commentedon May 14, 2011
Ahh, I guess I should have read the docs. But then looks like I am not the fist or only one so it's not as embarrassing. :)
I would support the proposal in bpo-11957 to make re flags non-int object