-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Closed as not planned
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-regextype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
According to the docs:
(...)
Matches whatever regular expression is inside the parentheses, and indicates the start and end of a group; the contents of a group can be retrieved after a match has been performed, and can be matched later in the string with the \number special sequence, described below. To match the literals '(' or ')', use\(
or\)
, or enclose them inside a character class:[(]
,[)]
.
However, when I try to use the \(
and \)
literals, I get:
SyntaxWarning: invalid escape sequence '\('
return bool(re.match('^Custom\([^)]*\)$', text))
Note that using the character classes [(]
and [)]
does work, but in my opinion re strings are hard enough to read as-is. ;-)
Tested on 3.12 and 3.13.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-regextype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error