Skip to content

Instantly share code, notes, and snippets.

@exavolt
Created January 19, 2011 16:30
Show Gist options
  • Save exavolt/786412 to your computer and use it in GitHub Desktop.
Save exavolt/786412 to your computer and use it in GitHub Desktop.
Simple Twitter like mention with RegEx
import re
_user_re = re.compile(r"""\B@([0-9a-zA-Z_]+)""")
def mentionify(text)
return _user_re.sub(r'@<a href="/user/\1">\1</a>', text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment