回 帖 发 新 帖 刷新版面

主题:求正则匹配一次代码

例子:我是中国人,同样也是玩论坛的人

比如说我想匹配第一个:“是”字后面出现的“是”就不匹配了!

回复列表 (共2个回复)

沙发

<%
'不知是不是这种效果?
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)
%>

板凳


~{2;JGNROkR*5DP'9{2;9};9JGP;P;Dz~}

我来回复

您尚未登录,请登录后再回复。点此登录或注册