最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp正则表达式过滤内容中的联系方式
时间:2022-06-30 10:50:54 编辑:袖梨 来源:一聚教程网
function repnum(strng) '以数组返回
i = 0
set regex = new regexp
regex.pattern = "(d+)" '"[0-9]"
regex.ignorecase = true
regex.global = true
set matches = regex.execute(strng)
for each match in matches
'retstr = retstr &"
"& match.value
if len(match.value)>=5 then
strng = replace(strng, right(match.value,4),"***")
end if
i = i + 1
next
repnum = strng
end function
使用的时候就直接<%=repnum(content)%>就行了,运行结果是content字符串中的一些数字被换成***,起到隐藏联系方式的作用。如果觉得留下的数字多了,自己改一下这个函数里面相应的数字。
再补充一个相关的函数
功能:asp教程正则表达式提取字符串中所有的数字。
参数:strng为要提取的内容
function regexptest(strng) '以数组返回
i = 0
set regex = new regexp
regex.pattern = "(d+)" '"[0-9]"
regex.ignorecase = true
regex.global = true
set matches = regex.execute(strng)
for each match in matches
retstr = retstr &"
"& match.value '输出提取出来的数字
i = i + 1
next
regexptest = retstr
end function
使用方法<%=regexptest(content)%>,运行结果是content字符串中的所有数字,并换行。
相关文章
- 《弓箭传说2》新手玩法介绍 01-16
- 《地下城与勇士:起源》断桥烟雨多买多送活动内容一览 01-16
- 《差不多高手》醉拳龙技能特点分享 01-16
- 《鬼谷八荒》毕方尾羽解除限制道具推荐 01-16
- 《地下城与勇士:起源》阿拉德首次迎新春活动内容一览 01-16
- 《差不多高手》情圣技能特点分享 01-16