asp html 字符串截取,asp截取字符串函数代码(过滤html标签)

function imgstr(str)

dim regex

set regex = new regexp '建立正则表达式。

regex.pattern = "]+){1}[^<>]*>(

33795.htm]*)(src=)('|"&chr(34)&"| )?(.[^'|s|"&chr(34)&"]*)(.)(jpg|gif|png|bmp|jpeg)('|"&chr(34)&"|s|>)(.[^>]*)(>)" '设置模式。

regex.ignorecase = true '设置是否区分字符大小写。

regex.global = true '设置全局可用性。

set matches = regex.execute(str) '执行搜索。

for each match in matches '遍历匹配集合。

imgstr = imgstr + replace(match.submatches(1),"productshow.asp?articleid=","")&"*****"

imgstr = imgstr + match.submatches(6)&"."&match.submatches(8)&"*****"

imgstr = imgstr + replace(match.submatches(10),"width='199' height='134' alt=","") & "

"

next

end function

'纯字符截取函数

function cutstr(str,strlen)

if str = "" then

cutstr = "cutstr函数异常:字符串为空"

exit function

end if

'------------来源长度检查

if strlen = "" then

cutstr = "cutstr函数异常:长度未指定"

exit function

end if

if cint(strlen) = 0 then

cutstr = "cutstr函数异常:长度为0"

exit function

end if

'----------检测来源字符长度

dim l,t,c,i

l=len(str)

t=0

'----------循环截取字符

for i=1 to l

c=abs(asc(mid(str,i,1)))

'------判断是否汉字

if c>255 then

t=t+2

else

t=t+1

end if

'------判断是否到达指定长度

if t>=strlen then

cutstr=left(str,i)&".."

exit for

else

cutstr=str

end if

next

cutstr=replace(cutstr,chr(10),"")

end function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值