主题:求正则匹配一次代码
hxf4244
[专家分:30] 发布于 2007-06-20 10:33:00
例子:我是中国人,同样也是玩论坛的人
比如说我想匹配第一个:“是”字后面出现的“是”就不匹配了!
回复列表 (共2个回复)
沙发
longlong16 [专家分:10670] 发布于 2007-06-20 12:33:00
<%
'不知是不是这种效果?
Function TestRegExp(myPattern, myString)
Set objRegExp = New RegExp
objRegExp.Pattern = myPattern
objRegExp.IgnoreCase = True
objRegExp.Global = True
''Test whether the String can be compared.
If (objRegExp.Test(myString) = True) Then
''Get the matches.
Set colMatches = objRegExp.Execute(myString) '' Execute search.
For Each objMatch In colMatches '' Iterate Matches collection.
RetStr = RetStr & "Match found at position "
RetStr = RetStr & objMatch.FirstIndex & ". Match Value is ''"
RetStr = RetStr & objMatch.Value & "''." & vbCrLf
Next
Else
RetStr = "String Matching Failed"
End If
TestRegExp = RetStr
End Function
pp = TestRegExp("是(.)*是","我是中国人,同样也是玩论坛的人")
response.Write(pp)
%>
板凳
hxf4244 [专家分:30] 发布于 2007-06-20 17:23:00
~{2;JGNROkR*5DP'9{2;9};9JGP;P;Dz~}
我来回复