客户要求保存原有的img已在的属性,郁闷,继续改
代码如下:
function shownew(content,ntype)
shownew = ""
if(ntype = 1) then
shownew = shownew &" <TABLE width=100% >"
shownew = shownew &"<TR>"
shownew = shownew &" <TD width=700 align=center style='word-break:break-all' valign=top>"&ShowPic(content)&"</TD>"
shownew = shownew &"</TR>"
shownew = shownew &"<TR>"
shownew = shownew &" <TD valign=top style='word-break:break-all'>"&OnlyWord(content)&"</TD>"
shownew = shownew &"</TR>"
shownew = shownew &"</TABLE>"
elseif (ntype = 2) then
shownew = shownew &" <TABLE width='100%'>"
shownew = shownew &"<TR>"
shownew = shownew &" <TD style='word-break:break-all' valign=top>"&OnlyWord(content)&"</TD>"
shownew = shownew &"</TR>"
shownew = shownew &"<TR>"
shownew = shownew &" <TD align=center width=700 valign=top style='word-break:break-all'>"&ShowPic(content)&"</TD>"
shownew = shownew &"</TR>"
shownew = shownew &"</TABLE>"
elseif (ntype = 3) then
shownew = shownew &"<TABLE>"
shownew = shownew &"<TR>"
shownew = shownew &"<TD width=100 align=center valign=top>"&ShowPic(content)&"</TD>"
shownew = shownew &"<TD width=80% style='word-break:break-all' valign=top>"&OnlyWord(content)&"</TD>"
shownew = shownew &"</TR>"
shownew = shownew &"</TABLE>"
elseif (ntype = 4) then
shownew = shownew &"<TABLE>"
shownew = shownew &"<TR>"
shownew = shownew &"<TD width=80% valign=top style='word-break:break-all'>"&OnlyWord(content)&"</TD>"
shownew = shownew &"<TD width=100 valign=top align=center>"&ShowPic(content)&"</TD>"
shownew = shownew &"</TR>"
shownew = shownew &"</TABLE>"
else
shownew = shownew &content
end if
end function
'显示提取的图片
function ShowPic(strng)
set regEx2 = new RegExp
regEx2.Pattern = "(src=)('|"&CHR(34)&"| )?(.[^'| |"&CHR(34)&"]*)(\.)(jpg|gif|png|bmp|jpeg)('|"&CHR(34)&"| |>)?" '设置模式。
regEx2.IgnoreCase = true '设置是否区分字符大小写。
regEx2.Global = True '设置全局可用性。
ShowPic = ""
ImageUrl= RegExpExecute(strng)
ImageUrls = Split(ImageUrl,"{|LDIV|}")
for i = LBound(ImageUrls) to (UBound(ImageUrls) - 1)
Set Matches2 = regEx2.Execute(ImageUrls(i)) '执行搜索。
For Each Match2 in Matches2 '遍历匹配集合。
'全Img标签
newpic = LCase(ImageUrls(i))
'如果没有自定义BORDER增加BOrder=0,其它原属性保留
if(instr(newpic,"border")=false) then newpic = left(newpic,len(newpic)-1) + " border='0' >"
if(instr(newpic,"width")=false) then newpic = left(newpic,len(newpic)-1) + " width='200' >"
newpic = "<a style='padding:20px' href='"&Match2.SubMatches(2)&Match2.SubMatches(3)&Match2.SubMatches(4)&"' >"& newpic & "</a>"
ShowPic = ShowPic & newpic
Next
next
Set regEx2 = nothing
end function
'从内容中提取图片
Function RegExpExecute(strng)
Dim regEx, Match, Matches '建立变量。
Set regEx = New RegExp '建立正则表达式。
regEx.Pattern = "(<)(.[^<]*)(sr