ASP 正则替换问题

来源:百度知道 编辑:UC知道 时间:2024/06/23 07:33:39
现在数据库中输出的字符串content,有定义字体大小:
<FONT size="1">内容</FONT> 要替换成:<FONT size="17">内容</FONT>
<FONT size="2">内容</FONT> 要替换成:<FONT size="18">内容</FONT>
<FONT size="3">内容</FONT> 要替换成:<FONT size="19">内容</FONT>
<FONT size="4">内容</FONT> 要替换成:<FONT size="20">内容</FONT>
<FONT size="5">内容</FONT> 要替换成:<FONT size="21">内容</FONT>
<FONT size="6">内容</FONT> 要替换成:<FONT size="22">内容</FONT>
<FONT size="7">内容</FONT> 要替换成:<FONT size="23">内容</FONT>

注意双半角号要保留:
那个循环该怎么做呢??如内容中包含多个:size=第二个开始就不替换了;
我现在改过的如下:
function stringHandle(s)
dim re
set re = new RegExp
re.pattern = "size=""(\d+)"""
Set Matches

<script type="text/vbscript">
//<![CDATA[
function stringHandle(s)
dim re
set re = new RegExp
re.pattern = "<FONT size=""(\d+)"">"
if re.test(s) = false then
stringHandle = s
exit function
end if
Set Matches = re.Execute(s)
stringHandle = re.Replace(s, reReplace(Matches(0).SubMatches(0)))
end function
function reReplace(s)
select case s
case "1":
reReplace = "<FONT size=""17"">"
case "2":
reReplace = "<FONT size=""18"">"
case "3":
reReplace = "<FONT size=""19"">"
case "4":
reReplace = "<FONT size=""20"">"
case "5":
reReplace = "<FONT size=""21"">"
case &quo