Skip to content

Instantly share code, notes, and snippets.

@doofusdavid
Created July 24, 2013 16:42
Show Gist options
  • Save doofusdavid/6072257 to your computer and use it in GitHub Desktop.
Save doofusdavid/6072257 to your computer and use it in GitHub Desktop.
quick and dirty wordpress slug generator in excel for data import from an existing database.
=LOWER(CLEAN(SUBSTITUTE(TRIM(C2)," ","-")))
@mread12
Copy link

mread12 commented Mar 26, 2015

Excellent! Thank you, but I did need to modify this script just a tad because I found that some of my product names had quotes in them ("). Here's how to remove those all in one script.

=LOWER(CLEAN(SUBSTITUTE(SUBSTITUTE(TRIM(C2)," ","-"),CHAR(34),"")))

@ChrisCinelli
Copy link

It obviously depend on your slug algorithm. However in google spreadsheet you can use

=LOWER(SUBSTITUTE(REGEXREPLACE(REGEXREPLACE(TRIM(C2),"[^a-zA-Z0-9\s]",""),"\s{2,}"," ")," ","-"))

In Excel you will have to implement REGEXREPLACE as a macro (it should not be too difficult)

@cpescott
Copy link

My gawd I need this - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment