Issue 33658: Introduce a method to concatenate regex patterns (original) (raw)

Issue33658

Created on 2018-05-27 08:53 by aleskva, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg317787 - (view) Author: Ales Kvapil (aleskva) Date: 2018-05-27 08:53
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)?
msg317829 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-28 08:16
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. pats = [r'(?m:^line.continues$)', r'(?s:begin.*?end)']
History
Date User Action Args
2022-04-11 14:59:00 admin set github: 77839
2018-05-28 08:16:03 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2018-05-27 11:19:29 THRlWiTi set nosy: + THRlWiTi
2018-05-27 08:53:27 aleskva create