rt
---------------------------------------------------------------
正则表达式
1
2Function RegExpTest(patrn, strng)
3Dim regEx, Match, Matches '建立变量。
4Set regEx = New RegExp '建立正则表达式。
5regEx.Pattern = "/^\d、$/"'设置模式。
6regEx.IgnoreCase = True '设置是否区分字符大小写。
7regEx.Global = True '设置全局可用性。
8Set Matches = regEx.Execute(strng) '执行搜索。
9For Each Match in Matches '遍历匹配集合。
10RetStr = RetStr & "Match found at position "
11RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
12RetStr = RetStr & Match.Value & "'." & "
<br/>
1"
2Next
3RegExpTest = RetStr
4End Function
5response.write RegExpTest("[ij]s.", "IS1 Js2 IS3 is4")
---------------------------------------------------------------
1
2function UBB_FiltrateBadWords(tempStr)
3Dim Str
4Dim FiltrateBadWordString_Temp,i
5names=split(tempStr,"、")
6for i=0 to ubound(names)
7names(i)=Replace(names(i), "、", "")
8if cint(names(i))<=36 then
9if str<>"" then
10Str = Str+"、"+names(i)
11else
12str=names(i)
13end if
14end if
15next
16UBB_FiltrateBadWords = Str
17end function
18Form_Title = UBB_FiltrateBadWords("12、45、23") '写上你要写的数字及顿号
19
1=Form_Title
---------------------------------------------------------------
1<html>
2<head>
3<title> New Document </title>
4<meta content="EditPlus" name="Generator"/>
5<meta content="" name="Author"/>
6<meta content="" name="Keywords"/>
7<meta content="" name="Description"/>
8<script language="JavaScript">
9<!--
10function check()
11{
12var re=/[^\d、]/ig;
13var str=document.f1.t1.value;
14var mstr=str.match(re);
15//先判断有没有非法字符
16if (mstr!=""&&mstr!=null)
17{
18alert("有非法字符"+mstr);
19return false;
20}
21var re2=/\d+/ig;
22//再判断有没有有超过大于36的数字
23var mstr2=str.match(re2)
24for(i=0;i<mstr2.length;i++)
25{if (mstr2[i]>=36)
26{
27alert(mstr2[i]+"大于36");
28}
29}
30}
31//-->
32</script>
33</head>
34<body>
35<form action="" method="POST" name="f1"><input name="t1" type="text"/><input onclick="check()" type="button" value="check"/>
36</form>
37</body>
38</html>