Replace()替换问题

来源:百度知道 编辑:UC知道 时间:2024/05/16 18:13:55
我用XMLHTTP组件取得一网页源代码中有如下一段代码,我想完全替换为空
<tr>
<td height="66" align="right" colspan="3" valign="top">
<!--首页顶部广告开始-->
<SCRIPT language=javascript src="/ads/1000n/list_top.js" type=text/javascript></SCRIPT>
<!--首页顶部广告开始--></td>
</tr>

我自己定义一个变量来获得替换后的值
Dim Http=Replace(这个变量我知道"这里是上面的内容","这里是为空")

我想请问上面的内容是不是在替换是要进行转义,如果要,请问怎么转,谢谢
请写出替换代码吧

不用替换,只需要把你不需要的这段代码从整个源代码中去掉就可了.
你分析一下这段代码有个特征是list_top.js,那就可以从它开始前面的<tr>到后面的</tr> 中间的部分全部去掉就可以了.
比如c#写法如下:(大小写我没有按规则,你调整下)
string content = 网页的全部源代码字符串;
int begin = content.indexof("list_top.js");
begin = (content.substring(0,begin)).lastindexof("<tr>");
int end = content.indexof("</tr>",begin) + 5;
content = content.remove(begin,end-begin);
最后content就是你需要的部分了.

你想改什么 我不清楚 不过 replace的用法 我可以解释一下 就举个例吧
replace(a,b,"c")

new=replace(这是一个实例,实例,"<font color=red>实例</font>")

new 得出的结果是 这是一个实例 其实实例是显示 红色

replace是将a里面的内容 b 以c来替换掉 的意思 !
至于你想换什么 我也不清楚你说什么 所以只有说下replace的用法

不用转义