最新下载
热门教程
- 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字符串中的所有数字,并换行。
相关文章
- 以闪亮之名海谕遥音套装细节展示攻略 05-09
- 碧蓝航线文琴佐焦贝蒂技能属性一览攻略 05-09
- 以闪亮之名新套海报捏脸数据id攻略 05-09
- DNF手游小队突袭第三期怪物有哪些打法 05-09
- DNF手游幻影马戏团第二幕新增装备汇总攻略 05-09
- 火影忍者手游黑绝技能动图展示攻略 05-09