Python: Replace/remove string between two delimiters/characters

This Python code helps you to

  • to replace a string between two delimiters or characters
  • delete/remove string between two characters or delimiters

Python code to replace string between two delimiters

Python code to delete/remove string between two characters/delimiters

Replace 5th line of above code with below one

Note: This code works in both Python 2 and 3

Read below post if you want to get/find sub string between two delimiters/characters within a string

https://gethowstuff.com/python-script-extract-string-two-delimiters/