Dim reg As System.Text.RegularExpressions.Regex
Dim strPattern As String = "[/u4e00-/u9fa5]"
If reg.IsMatch("我的世界abc", strPattern) = True Then
MsgBox("有汉字")
Else
MsgBox("没汉字")
End If
Dim strPattern As String = "[/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
本文介绍了一种使用正则表达式来检测字符串中是否包含中文字符及全角字符的方法。通过两个不同的正则表达式模式,可以有效地判断输入的文本中是否存在特定的字符类型。
1234

被折叠的 条评论
为什么被折叠?



