asp提取内容中的手机号码,qq,网址的正则代码

  常用的正则匹配表达式

  正则表达式--验证手机号码: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]*

  提取信息中的双字节字符串 (汉字):[^\x00-\xff]*

  用到的函数(第一个参数为正则表达式,第二个为字符串):

  

复制代码 代码如下:

  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

  Next

  RegExpTest = RetStr

  End Function