Message399977
From my understanding, "|" should match either the RegEx on the left or the RegEx on the right of the pipe
>>> help(re):
"|" A|B, creates an RE that will match either A or B.
With re.search(), the pattern below matches 'cool' as well as 'foo'
>>> re.search('(foo)|cool?', 'foo bar cool foobar coolbar')
<re.Match object; span=(0, 3), match='foo'>
>>> re.search('(foo)|cool?', 'cool')
<re.Match object; span=(0, 4), match='cool'>
But, the same pattern and strings won't match 'cool' if used with re.findall() or re.finditer() because of how they work when capture-groups are present in the pattern. |
|
Date |
User |
Action |
Args |
2021-08-20 16:02:18 | rondevous | set | recipients:
+ rondevous, docs@python, serhiy.storchaka, veky |
2021-08-20 16:02:18 | rondevous | set | messageid: <1629475338.81.0.577131597297.issue44940@roundup.psfhosted.org> |
2021-08-20 16:02:18 | rondevous | link | issue44940 messages |
2021-08-20 16:02:18 | rondevous | create | |
|