fork download
  1. # your code goes here
  2. import re
  3. input="""
  4. def func1 options
  5. some code here
  6. def inner_func1 inner_options
  7. some code here
  8. end
  9. some more code here
  10. end
  11. """
  12. replacement="""
  13. def new_func1 options
  14. new code here
  15. end
  16. """
  17. print(re.sub(r"(?:^|\n)([\t ]*?)def func1 options[\s\S]*?\n\1end",replacement,input),end='')
Success #stdin #stdout 0.02s 9596KB
stdin
Standard input is empty
stdout
def new_func1 options
    new code here
end