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.

Title: Documentation for regular expression alphanumeric matching are swapped.
Type: Stage: resolved
Components: Documentation Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: dananntang, docs@python, xiang.zhang
Priority: normal Keywords:

Created on 2016-05-25 02:24 by dananntang, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg266291 - (view) Author: dananntang (dananntang) Date: 2016-05-25 02:24
Section 7.2.1. Regular Expression Syntax

Documentation for \w and \W are wrong.
To be specific:
\w is to match any non-alphanumeric character, while \W is to match alphanumeric character

Fix: swap documentation for \w and \W
msg266292 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-05-25 02:36
I don't think no need to swap. The current doc is right.

>>> re.findall(r'\W+', 'abcd123_#@@@@')
>>> re.findall(r'\w+', 'abcd123_#@@@@')

It's apparent that \w match alphanumeric and \W vice versa.
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71303
2016-05-25 02:41:23zach.waresetstatus: open -> closed
resolution: not a bug
stage: resolved
2016-05-25 02:36:26xiang.zhangsetnosy: + xiang.zhang
messages: + msg266292
2016-05-25 02:24:52dananntangcreate