space line
space line
space line
space line
space line
您现在的位置是: 技术文章>>

ASP中正则表达式匹配双引号

发布日期 2008-10-14 6:37:05
作者 shemily
出处 重用网
浏览次数 ...
今日浏览 ...
本月浏览 ...
我要留言 我要留言
space line
摘要
ASP中用正则表达式匹配双引号的方法
space line
详细内容

VBScript手册中,关于正则表达式的说明是:

双引号括起来的一个字符串表达式,如:

"oncecode.com"

可用来匹配字符串中的含有“oncecode.com”域名的字符。

而如果要匹配双引号本身

则需要加反斜杠“\”,

并且用两个双引号表示一个双引号;

测试代码如下:

<%


dim str
str = "<a href=""test"" target=""_blank"">test</a>"
response.write(str&"<br/>")
response.write(replace(str," target=\""_blank\""","")&"<br/>")

response.write(execRE(" target=\""_blank\""","",str))

Function execRE(re, rp, content)
 ´---replace re in content with rp---
 set oReg = New RegExp
 oReg.Pattern = re
 oReg.Global=True
 Set Matches = oReg.Execute(content)
   For Each Match in Matches      ´replace them
  content=replace(content,Match.value,rp)
   Next

 execRE = content
End Function

%>

结果如预期的一样,会将字符串中的target="_blank"删除。

 

 

space line
我要留言 我要留言    
space line
space line
space line
space line
赞助商提供
space line
space line