Created
July 26, 2015 10:46
-
-
Save mapkyca/65ca3f1adf6954bab11e to your computer and use it in GitHub Desktop.
Quick python regex callback example, for my memory
This file contains 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 | |
def callback(match): | |
return "<a href=\"http://github.com/%s>%s</a>" % (match.group(0), match.group(0)) | |
string = "this is a #test #32345 dfsdf" | |
print re.sub('#[0-9]+', callback, string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment