Created
November 23, 2016 18:49
-
-
Save myano/01428eddb097799a34b3c9466279d449 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
txt = 'some smoe msoe soem http://www.google.com/meep/peem/peme soMe sMoe Msoe soeM https://www.google.com/meep/peem/pmep/ soem msoe smoe some' | |
def my_replace(match): | |
if not str(match.group()).startswith('http'): | |
return re.sub('(?i)m', '_', match.group()) | |
else: | |
return match.group() | |
print re.sub(r'\S+', my_replace, txt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment