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
{{ message }}
Repository navigation
Introduce a method to concatenate regex patterns #77839
After removing inline flags (deprecated in https://bugs.python.org/issue22493) piping patterns will not work:
pats = [r'(?m)^line.continues$', r'(?s)begin.*?end']
re.compile('|'.join(pats))
Maybe there should be introduced some method to merge patterns (similar to re.escape)?
This is not trivial task because inline flags with global scope can be occurred in any part of the pattern (although using them not at the start of the pattern is deprecated).
But starting with 3.7 you can use inline flags with local scope. This will allow you to use simple string concatenation.
Activity
aleskva commentedon May 27, 2018
After removing inline flags (deprecated in https://bugs.python.org/issue22493) piping patterns will not work:
pats = [r'(?m)^line.continues$', r'(?s)begin.*?end']
re.compile('|'.join(pats))
Maybe there should be introduced some method to merge patterns (similar to re.escape)?
serhiy-storchaka commentedon May 28, 2018
This is not trivial task because inline flags with global scope can be occurred in any part of the pattern (although using them not at the start of the pattern is deprecated).
But starting with 3.7 you can use inline flags with local scope. This will allow you to use simple string concatenation.