查看: 276  |  回复: 0
ASP 提取字符串中的中文字符,不含标点符号
楼主
发表于 2023年5月24日 16:30
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<%
Dim str
str = "<div title='欢迎访问,码农库。 www.MaNongKu.com' class='desc'>"

response.write f_GetChinese(True, str)
'Gloabl:搜索全局,str:被检索字符串

Function f_GetChinese(ByVal global,ByVal str)
    Dim reg, macher, count, i, temp
    temp = ""

    Set reg = New RegExp
    reg.Pattern = "[\u4e00-\u9fa5]+"
    reg.Global=global
    Set macher = reg.Execute(str)

    count = macher.count

    If count > 0 Then
        For i = 0 To count - 1
            temp=temp&macher(i)
        Next
    End If
    f_GetChinese = temp
End Function
%>

运行结果:

欢迎访问码农库


您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2024 MaNongKu.com