access字段里除了英文字母,其他的字符都去掉的语句
我想实现将字段里的英文字母保留,其他的都去除,应该怎么写语句呀?(在数据库里操作)。望前辈指教,谢谢
或者引用 Microsoft VBScript Regular Expressions xx,用正则表达式处理.
Public Function getEnStr(strData As String) As String Dim i As Integer Dim iAsc As Integer Dim str As String Dim strMatch As String If Len(strData) = 0 Then getEnStr = "" Exit Function End If For i = 1 To Len(strData) str = Mid(strData, i, 1) iAsc = asc(str) If iAsc >= 65 And iAsc <= 90 Or iAsc >= 97 And iAsc <= 122 Then strMatch = strMatch + str End If Next getEnStr = strMatch End Function Public Function getEn(strData As String) As String Dim re As New RegExp Dim Match, Matches Dim strMatch As String If Len(strData) = 0 Then getEn = "" Exit Function End If re.IgnoreCase = True re.Global = True re.Pattern = "[a-z]+" If re.Test(strData) Then Set Matches = re.Execute(strData) For Each Match In Matches strMatch = strMatch + Match.Value Next End If getEn = strMatch End Function Dim strData As String strData = "v#$ #%打 就b々了2#【%#a %343 撒 u?ャъ┛╋┝ΥΦΩ酒 疯##V㈦㈧㈩???㊣?āB┎A" Debug.Print getEnStr(strData), getEn(strData)