Try fixing regex incompatibility#1067
Conversation
|
Why is |
|
Can confirm this has no change in behaviour (and should be merged). The aim of this code is to wrap digits with named groups. The desired behaviour is preserved as: The current breakage is due to some extra escaping being desired by Currently the code uses For some reason, that still escapes me, # Fix 1: sub with triple escape
DIGIT_GROUP_PATTERN.sub('?P<n>\\\\d+', pattern) # => (?P<n>\\d+[.,]?\\d*) days ago
# Fix 2: sub with raw double escape
DIGIT_GROUP_PATTERN.sub(r'?P<n>\\d+', pattern) # => (?P<n>\\d+[.,]?\\d*) days ago
# Fix 3 (as in this PR): ditch sub and do it using builtins
pattern.replace('\\d+', '?P<n>\\d+') # => (?P<n>\\d+[.,]?\\d*) days agoIt might also be wise to expand the pattern slightly to: pattern.replace('(\\d+', '(?P<n>\\d+')as if anyone adds a |
|
Makes sense. However:
|
|
Made those changes #1095 here 👍 |
Fixes #1045
Based on #1045 (comment)