欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-08-11 07:52:13
常用的正则匹配表达式 正则表达式--验证手机号码:13[0-9]{9} 实现手机号前带86或是+86的情况:^((\+86)|(86))?(13)\d{9}$ 电话号码与手...
常用的正则匹配表达式

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