Asp實現檢測字符串是否爲純字母和數字組合的函數

01
<%
02
'**
03
'函數:CheckString(strng)
04
'參數:strng,待驗證字符串
05
'描述:檢測字符串是否爲純字母和數字組合
06
'示例:CheckString(strng)
07
'**
08
Function CheckString(strng)
09
CheckString = true
10
Dim regEx, Match
11
Set regEx = New RegExp
12
regEx.Pattern = "^[A-Za-z0-9]+$"
13
regEx.IgnoreCase = True
14
Set Match = regEx.Execute(strng)
15
if match.count then CheckString= false
16
End Function
17
'**
18
'函數:CheckChinese(strng)
19
'參數:strng,待驗證字符
20
'描述:檢測是否爲中文字符,返回值:中文爲true,否則false
21
'示例:CheckChinese(strng)
22
'**
23
Function CheckChinese(strng)
24
CheckChinese = true
25
Dim regEx, Match
26
Set regEx = New RegExp
27
regEx.Pattern = "||#|\&|\?|\@|\%|*|\/|.|\,|\;|\'|\:|-|_|+|\^|\""|\=|\<|\>|\ "
28
regEx.IgnoreCase = True
29
Set Match = regEx.Execute(strng)
30
if match.count then CheckChinese= false
31
End Function
32
%>

本文原創自news.mkq.online

版權聲明:本文爲原創文章,版權牛站新聞所有
轉載請註明http://www.niuzhan.com/keji/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章