Created
July 24, 2013 20:53
-
-
Save doofusdavid/6074454 to your computer and use it in GitHub Desktop.
VBScript version of WordPress' santitize_title_with_dashes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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