- <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>