我想在這些html代碼中,用ASP解決,比如下面這段html代碼:
strHTML="<a href="http://www.xx.com" title="點擊此注冊">會員號</a>,注冊會員將讓您擁有更多的權限,<img alt="注冊" title="注冊" src="https://img.uj5u.com/2020/11/18/155339180624381.gif">"
我只想把凡是有"注冊"兩個字的,替換成<a href="https://bbs.csdn.net/topics/xxx.com">注冊</a>的,但html里有“title 或 alt 屬性”有"注冊"兩個字的,不需要替換,要怎么操作??
我是用,retStr=replace(strHTML,"注冊","<a href="https://bbs.csdn.net/topics/xxx.com">注冊</a>"),結果把圖片的alt屬性,還有title里面的"注冊"也替換了,這不是我想要的,變成這樣:
<a href="http://www.xx.com" title="點擊此<a href="https://bbs.csdn.net/topics/xxx.com">注冊</a>">會員號</a>, <a href="https://bbs.csdn.net/topics/xxx.com">注冊</a>會員將讓您擁有更多的權限,<img alt="<a href="https://bbs.csdn.net/topics/xxx.com">注冊</a>" title="<a href="https://bbs.csdn.net/topics/xxx.com">注冊</a>" src="https://img.uj5u.com/2020/11/18/155339180624381.gif">
我想要的最終結果是:
<a href="http://www.xx.com" title="點擊此注冊">會員號</a>,<a href="https://bbs.csdn.net/topics/xxx.com">注冊</a>會員將讓您擁有更多的權限,<img alt="注冊" title="注冊" src="https://img.uj5u.com/2020/11/18/155339180624381.gif">
哪位大俠會的,幫忙解決一下,謝謝
uj5u.com熱心網友回復:
str = "<a href=""http://www.xx.com"" title=""點擊此注冊"">會員號</a>,注冊會員將讓您擁有更多的權限,<img alt=""注冊"" title=""注冊"" src=""/images/reg.gif"">"
pattern = "注冊(?!\"")"
Set RegEx = New RegExp
RegEx.Global = True
RegEx.IgnoreCase = True
RegEx.Pattern = pattern'"[a-z](\d+)[a-z]{3}"
str = regex.replace(str,"<a href=""baidu.com"">注冊</a>")
Set RegEx = Nothing
Response.Write str
Response.End
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/223492.html
標籤:ASP
