摘要:利用regex判斷是否有全型字
關於正規表達式的應用還有很多,以下是小弟之前處理全型字的小應用。
Function chkFullStr(ByVal value As String) As Boolean
For inti As Integer = 0 To value.Length - 1
Dim pat As String = "[\u4e00-\u9fa5]"
Dim rg As Regex = New Regex(pat)
Dim mh As Match = rg.Match(value(inti))
If (mh.Success) Or Hex(Asc(value(inti))).Length <> 2 Then
'漢字 或 全型
return True
End If
Next
return False
End Function
For inti As Integer = 0 To value.Length - 1
Dim pat As String = "[\u4e00-\u9fa5]"
Dim rg As Regex = New Regex(pat)
Dim mh As Match = rg.Match(value(inti))
If (mh.Success) Or Hex(Asc(value(inti))).Length <> 2 Then
'漢字 或 全型
return True
End If
Next
return False
End Function