<SCRIPT LANGUAGE="VBScript">
<!--
Dim reg,str,pattern
Set reg = new RegExp
str = "asdf00_asdfasfd"
pattern = "^[a-z][^_]*_[^_]*$"
reg.IgnoreCase = True
reg.Global = True
reg.Pattern = pattern
MsgBox(reg.Test(str))
//-->
</SCRIPT>
但是這樣必須包含"_"否則就會輸出falsh
要求的效果為 出現兩個 “_” 才false,並且沒有“_”的情況下也是true
<SCRIPT LANGUAGE="VBScript">
<!--
Dim re,str,temps
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
str="a_"
re.Pattern="^[a-z][^_]*_[^_]*$":str=re.Test(str)
temps=str
MsgBox(temps)
set re=Nothing
//-->
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
<!--
Dim re,str,temps
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
str="ad"
re.Pattern="^[a-z][^_]*_[^_]*$":str=re.Test(str)
temps=str
MsgBox(temps)
set re=Nothing
//-->
</SCRIPT>