Skip to content

Instantly share code, notes, and snippets.

@qqpann
Created August 4, 2017 17:22
Show Gist options
  • Save qqpann/7ded2adea061ab41e9ecac53a6178eb5 to your computer and use it in GitHub Desktop.
Save qqpann/7ded2adea061ab41e9ecac53a6178eb5 to your computer and use it in GitHub Desktop.
# string
string = 'A string with what to be replaced.'
result = string.replace('what to be replaced', 'what to replace')
# regex
import re
result = re.sub(r'what to be replaced', 'what to replace', string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment