python replace all in string code example
Example 1: replace url with text python
import re
text = re.sub('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))'+, '', text, flags=re.MULTILINE)
Example 2: python replace all occurrences in string
>>> 'no one knows how'.replace('no', 'yes')
'yes one kyesws how'
Example 3: python replace string
string.replace(old, new, count)