Chức năng: Xóa những ký tự không dùng đến trong chuổi
Ngôn ngữ: asp - Nhóm: string
CÚ PHÁP
string = RemChr(Input, Disallowed)
Sử dụng để xóa những ký tự không dùng đến trong một chuổi.
Input: Chuổi cần làm sạch.
Disallowed: Các ký tự không được sử dụng.
VÍ DỤ
<%
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 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
%>