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
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:
```
>>>