当前位置:编程学习 > asp >>

正则表达式asp拆分字母和数字组成的字符串的代码

Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = True ' 设置是否区分大小写。
regEx.Global = True ' 设置全程可用性。
Set Matches = regEx.Execute(strng) ' 执行搜索。
For Each Match in Matches ' 遍历 Matches 集合。
'RetStr = RetStr & Match.value&" " '值为123和44的数组
response.write Match.value&",<br>"
Next
'RegExpTest = RetStr
End Function
RegExpTest "(\d+|[a-za-z]+)", "123a44dd233"

看看循环得到的结果就知道了

稍微修改下就可以拆分汉字了!

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,