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
{{ message }}
Repository navigation
"\W" pattern with re.ASCII flag is not equivalent to "[^a-zA-Z0-9_]" #89621
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=<Date2021-10-13.09:28:14.946>created_at=<Date2021-10-13.09:10:37.218>labels= ['expert-regex', 'type-bug', '3.8', '3.9', '3.10', '3.7', 'invalid']
title='"\\W" pattern with re.ASCII flag is not equivalent to "[^a-zA-Z0-9_]"'updated_at=<Date2021-10-13.09:28:14.945>user='https://github.com/owentrigueros'
Activity
owentrigueros commentedon Oct 13, 2021
"\W" regex pattern, when used with
re.ASCII, is expected to have the same behavior as "[^a-zA-Z0-9_]" (see [1]).For example, the following
sub()callshould return the same as this one:
But it does not.
[1] https://docs.python.org/3/library/re.html#regular-expression-syntax
serhiy-storchaka commentedon Oct 13, 2021
It works as expected:
You just passed re.ASCII as the count argument, not as the flags argument.
>>> help(re.sub) Help on function sub in module re: