Asp正则表达式提取字符
作者:admin 日期:2012-07-18
正则表达式--验证手机号码:13[0-9]{9}
实现手机号前带86或是+86的情况:^((\+86)|(86))?(13)\d{9}$
电话号码与手机号码同时验证:(^(\d{3,4}-)?\d{7,8})$|(13[0-9]{9})
提取信息中的网络链接:(h|H)(r|R)(e|E)(f|F) *= *('|")?(\w|\\|\/|\.)+('|"| *|>)?
提取信息中的邮件地址:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
提取信息中的图片链接:(s|S)(r|R)(c|C) *= *('|")?(\w|\\|\/|\.)+('|"| *|>)?
提取信息中的IP地址:(\d+)\.(\d+)\.(\d+)\.(\d+)
提取信息中的中国手机号码:(86)*0*13\d{9}
提取信息中的中国固定电话号码:(\(\d{3,4}\)|\d{3,4}-|\s)?\d{8}
提取信息中的中国电话号码(包括移动和固定电话):(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}
提取信息中的中国邮政编码:[1-9]{1}(\d+){5}
提取信息中的中国身份证号码:\d{18}|\d{15}
提取信息中的整数:\d+
提取信息中的浮点数(即小数):(-?\d*)\.?\d+
提取信息中的任何数字 :(-?\d*)(\.\d+)?
提取信息中的中文字符串:[\u4e00-\u9fa5]*
- 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 ' 遍历匹配集合。
- RetStr = RetStr & "Match found at position "
- RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
- RetStr = RetStr & Match.Value & "'." & vbCRLF
- Next
- RegExpTest = RetStr
- End Function
- RegExpTest("is.", "IS1 is2 IS3 is4")
下一篇: VB 丢失MSXML 6.0 SP1下载
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: asp 正则表达式
相关日志:
广告位