regex for triple quote

后端 未结 5 671
我在风中等你
我在风中等你 2020-12-19 06:32

What regex will find the triple quote comments (possibly multi-line) in a Python source code?

5条回答
  •  -上瘾入骨i
    2020-12-19 07:09

    re.findall('(?:\n[\t ]*)\"{3}(.*?)\"{3}', s, re.M | re.S)
    

    captures only text within triple quotes that are at the begging of a line and could be preceded by spaces, tabs or nothing, as python docstrings should be.

提交回复
热议问题