You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ezio-melotti'closed_at=<Date2011-11-15.19:16:18.103>created_at=<Date2011-11-15.19:01:05.153>labels= ['expert-regex', 'type-bug', 'invalid']
title='Invalid expression error if a regex ends with a backslash'updated_at=<Date2011-11-15.19:16:18.102>user='https://bugs.python.org/mlesniew'
If a regular expression ends with a backslash, an exception is raised. Of course, the backslash has to be escaped. The simplest example, that causes the error is a regular expression, that should match only a single backslash:
You either have to double escape it (once for python and then for the regex engine) or use raw strings:
>>> re.match("\\\\", '\\').group()
'\\'
>>> re.match(r"\\", '\\').group()
'\\'
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: