如何验证字符串是否包含有效字符?
程序员文章站
2023-01-25 18:14:52
<%function teststring(somestring)tempstring = trim(so...
<%
function teststring(somestring)
tempstring = trim(somestring)
tempstring_length = len(tempstring)
tempstring_ok = true
for tempstring_pos = 1 to tempstring_length
tempstring_char = mid(tempstring,tempstring_pos)
tempstring_char_ansi = asc(tempstring_char)
if tempstring_char_ansi > 47 and tempstring_char_ansi < 123 then
' ansi字符中:a-z 是65-90,a-z是97-122,0-9是48-57
if tempstring_char_ansi > 57 and tempstring_char_ansi < 65 then
tempstring_ok = false
exit for
end if
if tempstring_char_ansi > 90 and tempstring_char_ansi < 97 then
tempstring_ok = false
exit for
end if
else
tempstring_ok = false
exit for
end if
next
teststring = tempstring_ok
end function
%>
上一篇: 如何检测字符串出现的次数?