"shownew = shownew &""showne...">
论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > asp教程
Tag:入门,文摘,实例,技巧,iis,表单,对象,上传,数据库,记录集,session,cookies,存储过程,注入,分页,安全,优化,xmlhttp,fso,jmail,application,防盗链,stream,组件,md5,乱码,缓存,加密,验证码,算法,ubb,正则表达式,水印,,日志,压缩,url重写,控件,函数,破解,触发器,socket,ADO,初学,聊天室,留言本,视频教程

使用正则表达式实现模式图片新闻.ASP

文章类别:asp | 发表日期:2008-10-5 20:47:43

'文字或特定图片模式显示新闻

function shownew(content,ntype)

shownew = ""

if(ntype = 1) then

shownew = shownew &" <TABLE width=100% >"
shownew = shownew &"<TR>"
shownew = shownew &" <TD width=600 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  width=600 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 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>"&ShowPic(content)&"</TD>"

shownew = shownew &"</TR>"
shownew = shownew &"</TABLE>"
else
 shownew = shownew & "<table><tr><td style='word-break:break-all'>"&content&"</td></tr></table>"
end if

end function

'显示提取的图片
function ShowPic(strng)

 ShowPic = ""
 ImageUrl= RegExpExecute(strng)

 ImageUrls = Split(ImageUrl,"<BR>")

 for i = LBound(ImageUrls) to (UBound(ImageUrls) - 1)

    ShowPic = ShowPic & ("<a href='"&ImageUrls(i)&"' target=_blank><image src='"&ImageUrls(i)&"' border='0' alt='按此在新窗口浏览图片' onload='javascript:if(this.width>180)this.width=180'></a>")

    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)&"<BR>"
    Next
   RegExpExecute = values
End Function

'删除内容中与图片有关的代码
function OnlyWord(strng)
  Set re=new RegExp
  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,"")
  Set re= nothing

end function

视频教程列表
文章教程搜索
 
Asp推荐教程
Asp热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058