最新下载
热门教程
- 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字符串中的所有数字,并换行。
相关文章
- 鹅鸭杀超级金水铃模式怎么玩 08-07
- 牧场物语风之繁华集市生日日期怎么看 08-07
- 口袋新旅途如何捕捉颓颓鹰 08-07
- DNF狄瑞吉版本女漫游加点攻略 08-07
- 鹅鸭杀士兵怎么玩 08-07
- DNF狄瑞吉版本协战师加点攻略 08-07