Ad Code

Use This Excel Function to Slugify / Handle-ize Any Text — Useful for Bulk URL Creation

 Periodically I run into the issue where I need to create a lot (thousands) of URLs from random strings of text, which may or may not include capital letters, spaces, hyphens, brackets, commas, etc.

Sometimes this is easiest done in a spreadsheet, so here’s an Excel function I baked up a couple years ago that I use to solve the particular problem of slugifying/handle-izing those URLs. It’s clunky, but functional*. Just replace “A2” with whatever cell you need to slugify, and voila.

*Only works for ASCII characters. Does not check for collisions!

Example

AS dsf a s1111#$ b'lue p"urple AsdoIj


becomes

as-dsf-a-s1111-blue-purple-asdoij


The Function

=LOWER(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2)," ","-"),"'",""),"""",""),"/",""),"?",""),".",""),">",""),"<",""),",",""),";",""),":",""),"[",""),"]",""),"}",""),"[",""),"{",""),"|",""),"\",""),"+",""),"=",""),"~",""),"`",""),"!",""),"@",""),"#",""),"$",""),"%",""),"^",""),"&",""),"*",""),"(",""),")",""),"#",""),"'",""),"""",""),"---","-"),"--","-")) 




 

 

 

Post a Comment

0 Comments