玉清金刚藤丸12袋 价格:求去掉链接的代码

来源:百度文库 编辑:高考问答 时间:2024/05/03 03:37:36
dim c1,c2
c1="<a href='http://www.abc.com' target='_blank'>http://www.abc.com</A>"
……
最终得到c2如下
c2="http://www.abc.com",即去掉了链接
asp代码,谢谢了!

使用正则表达式
例:
''封装成函数 regExReplace 正则替换
Function regExReplace(sSource,patrn, replStr)
Dim regEx, str1
str1 = sSource
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
regExReplace = regEx.Replace(str1, replStr)
End Function
dim c1,c2
c1="<a href='http://www.abc.com' target='_blank'>http://www.abc.com</A>"
c2=regExReplace(c1,"<[aA]\s+[^<>]+>(.+)<\/[aA]>","$1")
response.Write(c2)
欢迎使用如下调试工具:
http://www.ar114.com.cn/cai_tools/regexp.html

c2="<font style="text-decoration: none;">http://www.abc.com</font>"

以下代码经调试通过,
同样适用于提出多网址:
如有疑问,请随时与我联系
让我们共同携手建设百度知道!
'*****************************************
Dim c1, c2 , i
Dim regEx, cMatch, Matches
c1 = "<a href='http://www.abc.com' target='_blank'>http://www.abc.com</A>"
i = 0
'输出 c2 http://www.abc.com
Set regEx = New RegExp
regEx.Pattern = "((http|https|ftp):(\/\/|\\\\)((.)+?)(com|net|cn))"
'regEx.Pattern = "((.)+?)"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(c1)

For Each cMatch in Matches'遍历匹配集合。
If i mod 2 = 1 Then
c2 = c2 & cMatch.Value
End If
i = i + 1
Next
Set regEx = nothing
'此句不可少 释放对象
Response.Write c2

'*****************************************