Hi im just wondering if anyone knows how to remove special codes and spaces from a string in asp classic ?
thanks
Hi im just wondering if anyone knows how to remove special codes and spaces from a string in asp classic ?
thanks
don't know asp but just pass in a replace for everything that is not [^0-9a-fA-F]
You can easily remove a character from a string using the REPLACE function http://devguru.com/technologies/vbscript/13958.asp
You can implement Regular Expression to search the strings with the REGEXP OBJECT http://www.devguru.com/technologies/vbscript/14108.asp
@Jay: If you don't want to go the regular expression route, this could work for you:
<%
Option Explicit
Function alphanum(ByVal sText)
Dim sChr, i
If NOT IsNumeric(sText) Then
For i = 1 To Len(sText)
sChr = Mid(sText, i, 1)
If IsNumeric(sChr) Then
alphanum = alphanum & sChr
Else
If sChr = " " OR (Asc(LCase(sChr)) <= 122 AND Asc(LCase(sChr)) >= 97) Then
alphanum = alphanum & sChr
End If
End If
Next
Else
alphanum = sText
End If
End Function
Dim sInput
sInput = alphanum("$%^ (O_oh)")
sInput = Replace(sInput, " ", "")
Response.Write sInput
%>