URL Slug in ASP
-------------------------------------------------------------
<%
'Create Slug
Function CreateSlug(varCatSlug)
Dim Slug
'Everything to lower case
Slug = LCASE(varCatSlug)
' Replace - with empty space
Slug = Replace(Slug, "-", " ")
Dim re, re2
' Replace unwanted characters with space
Set re = New RegExp
re.Pattern = "[^a-z0-9\s-]"
re.Global = True
Slug = re.Replace(Slug, " ")
' Replace multple white spaces with single space
Set re2 = New RegExp
re2.Pattern = "\s+"
re2.Global = True
Slug = re2.Replace(Slug, " ")
Slug = Trim(Slug)
' Replace white space with -
Slug = Replace(Slug," ", "-")
CreateSlug = Slug
End Function
'End Create Slug
%>
-------------------------------------------------------------
<%
'Create Slug
Function CreateSlug(varCatSlug)
Dim Slug
'Everything to lower case
Slug = LCASE(varCatSlug)
' Replace - with empty space
Slug = Replace(Slug, "-", " ")
Dim re, re2
' Replace unwanted characters with space
Set re = New RegExp
re.Pattern = "[^a-z0-9\s-]"
re.Global = True
Slug = re.Replace(Slug, " ")
' Replace multple white spaces with single space
Set re2 = New RegExp
re2.Pattern = "\s+"
re2.Global = True
Slug = re2.Replace(Slug, " ")
Slug = Trim(Slug)
' Replace white space with -
Slug = Replace(Slug," ", "-")
CreateSlug = Slug
End Function
'End Create Slug
%>
No comments:
Post a Comment