VB 中如何用正则表达式匹配一个中文字符串?

解决方案 »

  1.   

        'Refer to:Microsoft VBScript Regular Expressions 5.5.
        Dim regexpObj As New RegExp
        regexpObj.Pattern = "[\u4e00-\u9fa5]{1,}"
        regexpObj.Global = True
        Dim matches,match,ret
        Set matches = regexpObj.Execute("adfjaslkdfjp你好sdgbvsdgsdfgsd")
        'Also see to SubMatches Collection.
        For Each match in matches
          ret = ret & vbCrLf & "Match found at " & match.FirstIndex & " Value is " & match.Value & "."
        Next
        MsgBox ret