How to Slugify a String in PHP
Here is a snippet for generating a URL friendly slug in PHP
function slugify($string){
return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string), '-'));
}
And you can use it in your code like so
...
Written by Sean Behan on 10/26/2017
How to Create a Slug in Python with the Re Module
There are a few 3rd party modules that do this sort of thing. But there is a pretty solution using out of the box Python functionality. You don't have to install any dependencies if you use the `re` module.
import re
text = ' asdfladf ljklasfj 2324...
Written by Sean Behan on 03/02/2017