This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: re special sequence '\w'
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: cybb20, georg.brandl
Priority: normal Keywords:

Created on 2005-09-09 09:40 by cybb20, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg26255 - (view) Author: ChristianJ (cybb20) Date: 2005-09-09 09:40
>>> rexp = re.compile('\\w', re.LOCALE)
>>> rexp.findall('_')
['_']
>>> '_'.isalnum()
False

While the Python docs say, that the underscore is 
supported, I strongly ask why this is so? 
The problem is that I want to match a sequence of 
alphanumeric characters but excluding the underscore.
If you defined \w to not support "_" anymore, people 
could easily check for the "_" as well with \w|_ .

My locale is "de_DE" but it does affect other locales as 
well.
msg26256 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-09-14 19:45
Logged In: YES 
user_id=1188172

\w matches the underscore since \w has been introduced in RE
syntax, and this was not in Python. This alone is sufficient
to justify this behavior.

Anyway, Python's behavior cannot change, too. Many REs would
become erroneous with such a change.

So closing as Won't fix.
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42359
2005-09-09 09:40:24cybb20create