过滤汉字的各类正则

来源:互联网 发布:组策略禁用了网络 编辑:程序博客网 时间:2024/05/22 14:08

        Dim reg As System.Text.RegularExpressions.Regex
        Dim strPattern As String
        '过滤汉字
        strPattern = "[/u4e00-/u9fa5]"
        If reg.IsMatch("我的世界abc", strPattern) = True Then
            MsgBox("有汉字")
        Else
            MsgBox("没汉字")
        End If

        '过滤全角字符
        strPattern = "[^/x00-/x7F]"
        If reg.IsMatch("我的世界abc。,,.", strPattern) = True Then
            MsgBox("有全角字符")
        Else
            MsgBox("有全角字符")
        End If

        '过滤特殊关键字
        strPattern = "胡[^/u4e00-/u9fa5]*锦[^/u4e00-/u9fa5]*涛"
        If reg.IsMatch("胡abc``锦我涛", strPattern) = True Then
            MsgBox("有特殊关键字")
        Else
            MsgBox("没特殊关键字")
        End If 

原创粉丝点击