strange behavior of parenthesis in python regex

后端 未结 3 1354
北海茫月
北海茫月 2021-01-28 20:45

I\'m writing a python regex that looks through a text document for quoted strings (quotes of airline pilots recorded from blackboxes). I started by trying to write a regex with

3条回答
  •  -上瘾入骨i
    2021-01-28 21:34

    You need to catch everything with an extra pair of parentheses.

    re.findall('(("|\').*?\\2)', page)
    

提交回复
热议问题