fork download
  1. import re
  2. s = "text\n!if\ntext1\n!endif\ntext2"
  3. s = re.sub("^!if$.*?^!endif$\s+", "", s, flags=re.S | re.M)
  4. print s
Success #stdin #stdout 0.09s 10864KB
stdin
Standard input is empty
stdout
text
text2