[issue45458] "\W" pattern with re.ASCII flag is not equivalent to "[^a-zA-Z0-9_]"

2021-10-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It works as expected: >>> re.sub(r'\W', '', '½ a', 0, re.ASCII) 'a' You just passed re.ASCII as the count argument, not as the flags argument. >>> help(re.sub) Help on function sub in module re: sub(pattern, repl, string, count=0, flags=0) Return the

[issue45458] "\W" pattern with re.ASCII flag is not equivalent to "[^a-zA-Z0-9_]"

2021-10-13 Thread Owen
New submission from Owen : "\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()` call ``` >>> re.sub('\W', '', '½ a', re.ASCII) '½a' ``` should return the same as this one: ``` >>>