Created
September 9, 2012 09:58
-
-
Save nbareil/3683564 to your computer and use it in GitHub Desktop.
self-contained slug generator
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
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