怀孕六个月吃什么好呢:求asp中的替换方法

来源:百度文库 编辑:神马品牌网 时间:2024/05/07 01:36:40
假设获取到一个变量,内容为:

aa <font color=red>fsdf</font>
aa <font color=red>fsdf</font>
aa <font color=red>fghgfhfg</font>
aa <font color=red>tryrt</font>
aa <font color=red>sdfsd</font>

“<font color=red>”和“</font>”之间的内容是不确定的,我现在想将“<font color=red>”和“</font>”之间的内容,包括“<font color=red>”和“</font>”都替换为内容“CC”,该怎么做?请举例列出代码,谢谢!

<%
str = "aa <font color=red>fsdf</font>aa<font color=red>fsdf</font>aa<font color=red>fghgfhfg</font>aa<font color=red>tryrt</font> aa<font color=red>sdfsd</font>"
while instr(str,"<font color=red>")>0
j = instr(str,"<font color=red>")
k = instr(str,"</font>")
str = left(str,j-1) + "CC" + right(str,len(str)-k-len("</font>"))
wend
response.write str
%>

使用正则表达式

你要替换的值是从哪里来,是通过表单输入来得到吗?
如果是,那就用正则表达式。