fork download
  1. import re
  2. txt = """
  3. Some initial text....
  4. Heading1
  5. Some other text.....
  6. Heading2
  7. Some more text....
  8. """
  9. new_text = re.sub('(Heading1)(.*)(Heading2)', r"\1 replaced with python script \3", txt, flags=re.DOTALL)
  10. print (new_text)
Success #stdin #stdout 0.03s 8688KB
stdin
Standard input is empty
stdout
Some initial text....
Heading1 replaced with python script Heading2
Some more text....