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

正则

客户要求保存原有的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 = "(<)(.[^<]*)(src=)('|"&CHR(34)&"| )?(.[^'|\s|"&CHR(34)&"]*)(\.)(jpg|gif|png|bmp|jpeg)('|"&CHR(34)&"|\s|>)(.[^>]*)(>)" '设置模式。

regEx.IgnoreCase = true '设置是否区分字符大小写。
regEx.Global = True '设置全局可用性。
Set Matches = regEx.Execute(strng) '执行搜索。
For Each Match in Matches '遍历匹配集合。
values=values&Match.Val

时间: 2024-09-01 03:33:55

使用正则表达式实现模式图片新闻(加强).ASP的相关文章

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

正则|正则 '文字或特定图片模式显示新闻 function shownew(content,ntype) shownew = "" if(ntype = 1) then shownew = shownew &" <TABLE width=100% >"shownew = shownew &"<TR>"shownew = shownew &" <TD width=600 style='

js 完美图片新闻轮转效果,腾讯大粤网首页图片轮转改造而来_javascript技巧

背景 我所想要的完美图片新闻轮转效果: 1.有新闻图片,有新闻标题,有轮转索引 2.鼠标未移到索引上,图片自动切换 3.鼠标移到索引上,显示现有图片,轮询停止 4.鼠标移开索引, 轮询继续 5.简洁明了,轻量级 (不依赖第三方任何文件,最好是原生js) 过程 找过很多图片轮询效果,和我的要求总是有些出入,不能十全十美.不是功能不全,就是太多花哨.本想自己开发一个,鉴于琐事拖延,迟迟未能开始. 偶尔看到 腾讯大粤网 的图片新闻,感觉就是我所想要的效果.但仔细试验,发现其不符合要求3.即没有轮询停止

asp图片显示问题-Asp中如何把一个网站的某个目录下的图片全部加载在页面

问题描述 Asp中如何把一个网站的某个目录下的图片全部加载在页面 界面代码 后台代码//图片存在//photo/US000001/我的相册/1.jpg//其中US000001是u.use_id可以获取的我的相册是DropDownListPhoto.SelectValue的值 private void DataListPhotoBind() {//其中u.use_id是用户id string path = Server.MapPath(""photo"") + &qu

百度新闻改版:图片新闻及视频新闻量有增

[科技讯]4月11日消息,百度新闻今日大幅改版.改版后的新闻首页更加清爽,同时增加了图片新闻和视频新闻显示量. 百度新闻首页做出调整的部分在微博热搜词和新闻热搜词的位置,而在视频新闻版块下添加了猜你喜欢栏目. 百度新闻首页各频道采用三竖栏布局,显示更加清晰,图片新闻和视频新闻显示量增加. 有分析认为,目前很多用户获取新闻的习惯正逐渐从门户网站转向百度新闻页面,百度新闻此次改版提高了用户体验,或将成为新浪.网易.搜狐.腾讯四大门户网站之外的第五大门户网站.

CMS系统发布广告或者图片新闻丢失图片

问题描述 CMS系统发布广告或者图片新闻丢失图片,重新修改图片的存放路径也照样丢失,第一天上传没问题,过二三天就找不到图片了,文件夹里也没有,数据库里有存放路径,不知道是什么原因导致的,好像有自动清理程序一样. 解决方案 解决方案二:你这是让大家一起跟你猜猜猜?你可以写个小程序用FileSystemWatcher监控目录下文件的变化情况,确认下都什么时候图片失踪的,另外你也可以遍历下项目,看下哪里有Delete的代码解决方案三:你看你服务器上面是不是隐藏了,或者是有什么还原的么?如果是程序删除的

各位实现图片新闻...给一点思路..

问题描述 像这样的图片新闻http://junshi.daqi.com/editor/slide/ent_slide/2408662/1.html如何实现呢...是存储在数据库..还是存储在目录里.数据库里的字段如何放呢..请哪位提示一下..给个思路就行.. 解决方案 解决方案二:数据库保存图片路径.一个主表,一个子表.主表保存标题之类的,子表保存图片路径和主表的ID.解决方案三:这个是放在数据库里的.<imgsrc="showimg.aspx?id=xxx"/>在页面上改

请问FLASH图片新闻如何实现,最好有源码

问题描述 请问FLASH图片新闻如何实现,比如新浪体育新闻那样的,最好有源码 解决方案 解决方案二:顶一下解决方案三:利用Java脚本访问后台变量读出数据库中的图片信息即可解决方案四:顶一下,有源码吗?解决方案五:???????????解决方案六:c#你面有个弄广告的啊

请问一下CSDN的图片新闻做法

问题描述 请问一下CSDN首页的图片新闻做法,它下面有页数,上面的图像的打开方式都不同,哪位有现成的代码就贴上来, 解决方案 解决方案二:急用啊解决方案三:那个图片轮换?解决方案四:就命解决方案五:就是左边的那个图骗新闻,

搜狐新闻客户端推Win8版 主打图片新闻

8月30日,三星推出全球首款WindowsPhone8手机,备受业内瞩目,而10月份,Windows8平板系统也将正式发布,该平台势必将成为除iOS和Android之外中文应用争夺的新战场.在 新的趋势下,近日,搜狐与微软合作推出搜狐新闻客户端Windows8V1.0版,率先成为支持微软windows8平板电脑的新闻客户端,而支持WindowsPhone8的搜狐新闻客户端也已在开发计划中.据了解,支持windows8平板电脑的搜狐新闻客户端将结合Windows8 大屏幕的设计理念,在用户阅读.产