Hi,
I'm using the following code to create a Slug from some input text:
Everything works when I use this:PHP Code:<%
Function CreateSlug(Title)
Dim Slug
Slug = LCASE(Title)
' Replace - with empty space
Slug = Replace(Slug, "-", " ")
' Replace unwanted characters with space
'Slug = Regex.Replace(Slug, "[^a-z0-9\s-]", " ")
' Replace multple white spaces with single space
'Slug = Regex.Replace(Slug, "\s+", " ").Trim()
Dim re, re2
Set re = New RegExp
Set re2 = New RegExp
re.Pattern = "[^a-z0-9\s-]"
re2.Pattern = "\s+"
Slug = re.Replace(Slug, "($1) $2-$3") // problem areas?
Slug = re2.Replace(Slug, " ") // problem areas?
Slug = Trim(Slug)
' Replace white space with -
Slug = Replace(Slug," ", "-")
Response.Write Slug
End Function
%>
converts to this-is-a-long-bit-of-textPHP Code:response.write CreateSlug("this is a long bit of text")
However when I start to add other characters, it goes wrong.
Am I misusing the Regular Expressions above?
Many thanks for any help.




Bookmarks