fork download
  1. import re
  2. rx = r'^#[^\r\n]*|"""(.*?)"""'
  3. s = "def foo():\n \"\"\"\n this\n here\n \"\"\"\n\n pass\n\n\n# def foo():\n# \"\"\"\n# this\n# here\n# \"\"\"\n# \n# pass"
  4. res = re.findall(rx, s, re.DOTALL|re.MULTILINE)
  5. print(list(filter(None, res)))
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
['\n    this\n    here\n    ']