51代码网ORACLEMYSQLSQL SERVER其它数据库java/jspasp/asp.netC/C++/VC++APP应用其它语言服务器应用
您现在的位置: 51代码网 >> 其它数据库 >> 文章正文

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

更新时间:2013-6-15:  来源:51代码网

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)

  • 上一篇文章:
  • 下一篇文章: 没有了
  • 赞助商链接
    推荐文章
  • 此栏目下没有推荐文章
  • {
    设为首页 | 加入收藏 | 友情链接 | 网站地图 | 联系站长 |