Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to slugify string in python

import re

def slugify(s):
  s = s.lower().strip()
  s = re.sub(r'[^ws-]', '', s)
  s = re.sub(r'[s_-]+', '-', s)
  s = re.sub(r'^-+|-+$', '', s)
  return s
Source by www.30secondsofcode.org #
 
PREVIOUS NEXT
Tagged: #slugify #string #python
ADD COMMENT
Topic
Name
8+5 =