Skip to content

Instantly share code, notes, and snippets.

@nbareil
Created September 9, 2012 09:58
Show Gist options
  • Save nbareil/3683564 to your computer and use it in GitHub Desktop.
Save nbareil/3683564 to your computer and use it in GitHub Desktop.
self-contained slug generator
def slugify(s):
import unicodedata, re
s = unicodedata.normalize('NFKD', unicode(s)).encode('ASCII', 'ignore')
s = re.sub('[^\w\s-]', '', s).strip().lower()
return re.sub('[-\s]+', '-', s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment