使用正则表达式实现模式图片新闻.ASP__教程 |
|
日期:2007-5-20 1:28:21 人气:177 [大 中 小] |
|
|
|
'文字或特定图片模式显示新闻
function shownew(content,ntype)
shownew = ""
if(ntype = 1) then
shownew = shownew &" " shownew = shownew &"" shownew = shownew &" "&ShowPic(content)&" | " shownew = shownew &" " shownew = shownew &"" shownew = shownew &" "&OnlyWord(content)&" | " shownew = shownew &" " shownew = shownew &" "
elseif (ntype = 2) then
shownew = shownew &" "
shownew = shownew &"" shownew = shownew &" "&OnlyWord(content)&" | " shownew = shownew &" " shownew = shownew &"" shownew = shownew &" "&ShowPic(content)&" | " shownew = shownew &" " shownew = shownew &" "
elseif (ntype = 3) then
shownew = shownew &""
shownew = shownew &"" shownew = shownew &""&ShowPic(content)&" | "
shownew = shownew &""&OnlyWord(content)&" | "
shownew = shownew &" " shownew = shownew &" "
elseif (ntype = 4) then
shownew = shownew &""
shownew = shownew &""
shownew = shownew &""&OnlyWord(content)&" | " shownew = shownew &""&ShowPic(content)&" | "
shownew = shownew &" " shownew = shownew &" " else shownew = shownew & "" end if
end function
'显示提取的图片 function ShowPic(strng)
ShowPic = "" ImageUrl= RegExpExecute(strng)
ImageUrls = Split(ImageUrl," ")
for i = LBound(ImageUrls) to (UBound(ImageUrls) - 1)
ShowPic = ShowPic & ("")
next
end function
'从内容中提取图片 Function 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 '遍历匹配集合。 values=values&Match.SubMatches(2)&Match.SubMatches(3)&Match.SubMatches(4)&" " Next RegExpExecute = values |
|
出处:本站原创 作者:佚名 |
|
|