RemChr Function:
Removes unwanted characters from a string.
Description:
The RemChr function is used to remove unwanted characters from a string. There are two required arguments, input and remove. The input argument is the string to clean. The disallowed argument is a string of disallowed characters in any order. RemChr returns the original string with any disallowed characters removed.
Syntax:
string = RemChr(Input, Disallowed)
Example:
<%
Dim Input, Disallowed
'--- String to clean Input = "sjsvnw)68&Y469$T_W$(*T+}D|3567808SDK49SO" & _ "DJ0570570Gosdnp SNDFG_S(*GH-S570570GN*4 jwt jtj+W$T )"
'--- Allow spaces, underscores and any integer or letter of the alphabet. '--- Remove anything else... Disallowed = "[]+=)(*&^%$#@!|\/?><,{}:;.-~`'" & chr(34) & vbCrLf & vbTab Response.Write RemChr(Input, Disallowed)
'--- remove spaces, tabs, linefeed carriagereturns... Disallowed = " " & vbTab & vbCrLf Response.Write RemChr(Input, Disallowed)
'--- remove numbers... Disallowed = "0123456789" Response.Write RmChr(Input, Disallowed)
'--- remove lower case letters... Disallowed = lcase("abcdefghijklmnopqrstuvwxyz") Response.Write RemChr(Input, Disallowed)
'--- remove upper case letters... Disallowed = ucase("abcdefghijklmnopqrstuvwxyz") Response.Write RemChr(Input, Disallowed)
%>
ASP Source Code:
<%
Private Function RemChr(byVal string, byVal remove) Dim i, j, tmp, strOutput strOutput = "" for j = 1 to len(string) tmp = Mid(string, j, 1) for i = 1 to len(remove) tmp = replace( tmp, Mid(remove, i, 1), "") if len(tmp) = 0 then exit for next strOutput = strOutput & tmp next RemChr = strOutput End Function
%>
|