regex for triple quote
Python is not a regular language and cannot reliably be parsed using regex.
If you want a proper Python parser, look at the ast module. You may be looking for get_docstring
.
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.