Skip to content

Instantly share code, notes, and snippets.

@mapkyca
Created July 26, 2015 10:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapkyca/65ca3f1adf6954bab11e to your computer and use it in GitHub Desktop.
Save mapkyca/65ca3f1adf6954bab11e to your computer and use it in GitHub Desktop.
Quick python regex callback example, for my memory
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