Function Repository Resource:

SlugifyString

Source Notebook

Process strings to make them more URL friendly

Contributed by: Cody Woodard

ResourceFunction["SlugifyString"][string]

gives URL-friendly version of string.

Details and Options

The following options can be given:
"ForceLowerCase"Trueforce string to be lowercase
IgnoreDiacriticsFalseif True, transliterates string
"SeparatorCharacter""-"character that replaces non-word characters

Examples

Basic Examples (1) 

Create a URL-friendly version of a string:

In[1]:=
ResourceFunction["SlugifyString"]["This is a sample title"]
Out[1]=

Scope (2) 

By default, this function transliterates into plain ASCII:

In[2]:=
ResourceFunction["SlugifyString"]["Vigenère Cipher"]
Out[2]=

This function removes symbols, but keeps letters and numbers:

In[3]:=
ResourceFunction[
 "SlugifyString"]["We\[CloseCurlyQuote]ve Come a Long Way in 30 Years (But You Haven\[CloseCurlyQuote]t Seen Anything Yet!)"]
Out[3]=

Options (4) 

Don’t force lowercase:

In[4]:=
ResourceFunction["SlugifyString"]["This Is A Sample Title", "ForceLowerCase" -> False]
Out[4]=

Don’t transliterate:

In[5]:=
ResourceFunction["SlugifyString"]["Vigenère Cipher", IgnoreDiacritics -> True]
Out[5]=

Use a different separator character:

In[6]:=
ResourceFunction["SlugifyString"]["This is a sample title", "SeparatorCharacter" -> "_"]
Out[6]=

Combining options:

In[7]:=
ResourceFunction["SlugifyString"]["This Is A Sample Title", "ForceLowerCase" -> False, "SeparatorCharacter" -> ""]
Out[7]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 04 December 2018

License Information