What regex will find the triple quote comments (possibly multi-line) in a Python source code?
I've found this one from Tim Peters (I think) :
pat = """
qqq
[^\\q]*
(
( \\\\[\000-\377]
| q
( \\\\[\000-\377]
| [^\\q]
| q
( \\\\[\000-\377]
| [^\\q]
)
)
)
[^\\q]*
)*
qqq
"""
pat = ''.join(pat.split(), '')
tripleQuotePat = pat.replace("q", "'") + "|" + pat.replace('q', '"')
But, as stated by bobince, regex alone doesn't seem to be the right tool for parsing Python code.
So I went with tokenize from the standard library.