Message337274
"\\-" is equivalent to the raw string r"\-" (that it, it has one backslash, followed by a hyphen). \X (where X is any ASCII non-letter, non-digit) matches the character itself (the escape does nothing except ensure the punctuation doesn't have any special regex meaning). So your pattern is equivalent to "-". Since re.match has an implicit anchor at the beginning of the string (making it roughly like "^-"), the string "\-" doesn't match.
Use raw strings consistently for your regular expressions to reduce the number of rounds of deescaping. re.match(r"\\-", "\\-") works as you expected. |
|
Date |
User |
Action |
Args |
2019-03-06 03:45:20 | josh.r | set | recipients:
+ josh.r, ezio.melotti, mrabarnett, lprice |
2019-03-06 03:45:20 | josh.r | set | messageid: <1551843920.3.0.824022952738.issue36206@roundup.psfhosted.org> |
2019-03-06 03:45:20 | josh.r | link | issue36206 messages |
2019-03-06 03:45:20 | josh.r | create | |
|