Skip to content

Instantly share code, notes, and snippets.

@doofusdavid
Created July 24, 2013 20:53
Show Gist options
  • Save doofusdavid/6074454 to your computer and use it in GitHub Desktop.
Save doofusdavid/6074454 to your computer and use it in GitHub Desktop.
VBScript version of WordPress' santitize_title_with_dashes
Function sanitize_title_with_dashes(title As String) As String
Dim oDoc As HTMLDocument
Set oDoc = New HTMLDocument
oDoc.body.innerHTML = title
title = oDoc.body.innerText
title = LCase(title)
title = Replace(title, " ", "-")
title = Replace(title, ".", "-")
Dim oReg As Object
Set oReg = CreateObject("VBScript.RegExp")
oReg.Global = True
oReg.IgnoreCase = True
oReg.Pattern = "[^a-z0-9 _-]"
title = oReg.Replace(title, "")
sanitize_title_with_dashes = title
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment