'文字或特定圖片模式顯示新聞
function shownew(content,ntype)
shownew = ""
if(ntype = 1) then
shownew = shownew &" <TABLE width=100% >"
顯示新 = 顯示新 &"<TR>"
shownew = shownew &" <TD width=600 style='word-break:break-all' valign=top>"&ShowPic(content)&"</TD>"
顯示新 = 顯示新 &"</TR>"
顯示新 = 顯示新 &"<TR>"
shownew = shownew &" <TD valign=top style='word-break:break-all'>"&OnlyWord(content)&"</TD>"
顯示新 = 顯示新 &"</TR>"
顯示新 = 顯示新 &"</TABLE>"
elseif (ntype = 2) 那麼
shownew = shownew &" <TABLE width='100%'>"
shownew = shownew &"<TR>"
shownew = shownew &" <TD style='word-break:break-all' valign=top>"&OnlyWord(content)&"</TD>"
顯示新 = 顯示新 &"</TR>"
顯示新 = 顯示新 &"<TR>"
shownew = shownew &" <TD width=600 valign=top style='word-break:break-all'>"&ShowPic(content)&"</TD>"
顯示新 = 顯示新 &"</TR>"
shownew = shownew &"</TABLE>"
elseif (ntype = 3) then
shownew = shownew &"<TABLE>"
shownew = shownew &"<TR>"
shownew = shownew &"<TD width=100 valign=top>"&ShowPic(content)&"</TD>"
shownew = shownew &"<TD width=80% style='word-break:break-all' valign=頂部>“&OnlyWord(內容)&”</TD>”
顯示新 = 顯示新 &"</TR>"
shownew = shownew &"</TABLE>"
elseif (ntype = 4) then
shownew = shownew &"<TABLE>"
shownew = shownew &"<TR>"
shownew = shownew &"<TD width=80% valign=top 樣式='word-break:break-all'>"&OnlyWord(內容)&"</TD>"
shownew = shownew &"<TD width=100 valign=top>"&ShowPic(content)&"</TD>"
shownew = shownew &"</TR>"
顯示新 = 顯示新 &"</TABLE>"
別的
shownew = shownew & "<table><tr><td style='word-break:break-all'>"&content&"</td></tr></table>"
end if
end function
'顯示提取的圖片
函數 ShowPic(strng)
ShowPic = ""
ImageUrl= RegExpExecute(strng)
ImageUrls = Split(ImageUrl,"<BR>")
for i = LBound(ImageUrls) 到 (UBound(ImageUrls) - 1)
ShowPic = ShowPic & ("<a href='ls"&ImageUrls) - 1) ShowPic = ShowPic & ("<a href='ls"&ImageUrls(i) &"' target=_blank><image src='"&ImageUrls(i)&"' border='0' alt='更多圖片新聞' onload='javascript:if(this.width>180)this .width= 180'></a>")
接下來
結束函數
'從內容中提取圖片
函數 RegExpExecute(strng)
Dim regEx, Match, Matches '建立變數。
Set regEx = New RegExp '建立正規表示式。
regEx.Pattern = "(src=)('|"&CHR(34)&"| )?(.[^'|s|"&CHR(34)&"]*)(.)(jpg|gif| png|bmp|jpeg)('|"&CHR(34)&"|s|>)?" '設定模式。
' regEx.Pattern = "(src=)('|"&CHR(34)&"| )?(.[^'| |"&CHR(34)&"]*)(.)(jpg|gif|png |bmp|jpeg)('|"&CHR(34)&"| |>)?" '設定模式。
'regEx.Pattern = "(s|S)(r|R)(c|C)=('|"+CHR(34)+")(w|\|/|.)+(' |“+CHR(34)+”| *|>)? '設定模式。
regEx.IgnoreCase = true '設定區分是否字元大小寫。
regEx.Global = True '設定全域分佈。
Set Matches = regEx.Execute(strng) '執行搜尋。
For Each Match in Matches '遍歷匹配集合。
值=值&Match.SubMatches(2)&Match.SubMatches(3)&Match.SubMatches(4)&"<BR>"
下一個
RegExpExecute = 值
End Function
'刪除內容中與圖片相關的程式碼
函數OnlyWord(strng)
設定 re=new 正規表示式
re.IgnoreCase = True
re.Global=True
re.Pattern = "(<)(.[^<]*)(src=)('|"&CHR(34)&"| )?(.[^'|s|"&CHR(34)&"] *)(.)(jpg|gif|png|bmp|jpeg)('|"&CHR(34)&"|s|>)(.[^>]*)(>)" '設定模式。
OnlyWord=re.Replace(strng,"")
設定re=無
結束函數