建站代码网

热门标签

正则表达式从字符串中提取数字(中文字符之间)

<% 

str = "编号 26 台名 26 局号 8216 场次 73-8 开彩 0^0^1^0^0^ 注单 100^0^0^0^0^ 赔彩 100^0^0^0^0^ 总赔 100"

'Response.Write RegExpTest("[0-9-^]+",str)(5)  '返回第一个匹配的字符串
response.Write ubound(RegExpTest("[0-9-^]+",str))
Function RegExpTest(patrn, strng)  '以数组返回
    Dim regEx, Match, Matches
    Dim i, RetStr()
    i = 0
    Set regEx = New RegExp
    regEx.Pattern = patrn
    regEx.IgnoreCase = True
    regEx.Global = True
    Set Matches = regEx.Execute(strng)
    For Each Match in Matches
'        RetStr = RetStr & Match.Value
        Redim Preserve RetStr(i)
        RetStr(i) = Match.Value
        i = i + 1
    Next
    RegExpTest = RetStr
End Function
 %>
X