求字段里除了英文字母,其他的字符都去掉的语句

homellq 2013-04-29 06:16:03
我想实现将字段里的英文字母保留,其他的都去除,应该怎么写语句呀?(在数据库里操作)。望前辈指教,谢谢!
...全文
187 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qmnx 2013-04-30
  • 打赏
  • 举报
回复

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)
qmnx 2013-04-30
  • 打赏
  • 举报
回复
或者引用 Microsoft VBScript Regular Expressions xx,用正则表达式处理.
qmnx 2013-04-30
  • 打赏
  • 举报
回复
写个自定义函数然 在Sql里调用
ACMAIN_CHM 2013-04-29
  • 打赏
  • 举报
回复
没有好办法,通过程序来实现吧。

7,732

社区成员

发帖
与我相关
我的任务
社区描述
Microsoft Office Access是由微软发布的关系数据库管理系统。它结合了 MicrosoftJet Database Engine 和 图形用户界面两项特点。
社区管理员
  • Access
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧