如何获得数据库中的图片链接地址?

yassee 2008-06-13 07:52:14
比如数据库中newscontent字段是用来保存提交的新闻内容的。内容里面包含有一些图片链接。我如何得到这些图片链接?

newscontent内容示例:
---示例1----------------------------------------
<P><STRONG>苏州:周庄诠释中国第一水乡 同里演绎小桥流水人家</STRONG></P>
<CENTER><IMG alt=""苏州:周庄诠释中国第一水乡 同里演绎小桥流水人家"" src=""http://i0.sinaimg.cn/cj/roll/20080331/885821569a47e903669db176898cc7b4.jpg""> <BR><BR></CENTER><!--IMG END--><!--IMG BEGIN-->
<CENTER><IMG alt=""苏州:周庄诠释中国第一水乡 同里演绎小桥流水人家"" src=""http://i0.sinaimg.cn/cj/roll/20071003/091336471a47c1d3a17510f00c032516.jpg""> <BR><BR></CENTER><!--IMG END-->
<P>  周庄:</P>
-----------------------------------------------
---示例2----------------------------------------
<P><IMG src=""/dyoa/htmledit/UploadFile/2008521174419724.jpg"" border=0></P>
<P><IMG src=""/dyoa/htmledit/UploadFile/2008521174453630.jpg"" border=0></P>
<P><IMG src=""/dyoa/htmledit/UploadFile/200852117453182.jpg"" border=0></P>
<P class=MsoNormal style=""MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.0""><I style=""mso-bidi-font-style: normal""><SPAN style=""FONT-SIZE: 13.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"">加强防范,力保平安。进一步加强公司的安全防范工作。在工作中,加大公司的管理力度,落实人防、物防、技防措施;深入开展矛盾纠纷排查调处,深入开展各项安全检查</SPAN></I><I style=""mso-bidi-font-style: normal""><SPAN lang=EN-US style=""FONT-SIZE: 13.5pt""><FONT face=""Times New Roman"">”</FONT></SPAN></I><I style=""mso-bidi-font-style: normal""><SPAN style=""FONT-SIZE: 13.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"">。</SPAN></I><I style=""mso-bidi-font-style: normal""><SPAN style=""FONT-SIZE: 13.5pt""><FONT face=""Times New Roman""> </FONT></SPAN></I><I style=""mso-bidi-font-style: normal""><SPAN style=""FONT-SIZE: 13.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"">制定完善方案,细化安保措施。制定完善各自的安全保卫,并充分考虑可能出现的情况和问题,细化工作措施,提高方案的针对性和可操作性。</SPAN></I><I style=""mso-bidi-font-style: normal""><SPAN lang=EN-US style=""FONT-SIZE: 13.5pt""><o:p></o:p></SPAN></I></P>
<P><IMG src=""/dyoa/htmledit/UploadFile/2008521174511490.jpg"" border=0></P>
<P><IMG src=""/dyoa/htmledit/UploadFile/2008521174519791.jpg"" border=0></P>
<P><IMG src=""/dyoa/htmledit/UploadFile/2008521174526252.jpg"" border=0></P>

------------------------------------------------

我想得到的是:
示例1:
http://i0.sinaimg.cn/cj/roll/20080331/885821569a47e903669db176898cc7b4.jpg
http://i0.sinaimg.cn/cj/roll/20071003/091336471a47c1d3a17510f00c032516.jpg

示例2:
/dyoa/htmledit/UploadFile/2008521174419724.jpg
/dyoa/htmledit/UploadFile/2008521174453630.jpg
.....
...全文
348 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
阿斯顿是的啊 2011-05-25
  • 打赏
  • 举报
回复
1111111111111111
hulangfy 2008-06-15
  • 打赏
  • 举报
回复
顶.....楼上好强
fishidea 2008-06-14
  • 打赏
  • 举报
回复
顶.....楼上好强....^_^
  • 打赏
  • 举报
回复
Content="<img height=11 src=http://a.gif width=10>adfas<img height=11 src=v.gif width=10>dfasf"
response.write savepic(Content)
response.end()

function savepic(str)
content=str&""
regstr="src\=.+?\.(gif|jpg)"
url=Replace(Replace(Replace(RegExp_Execute(regstr‚content)‚"'"‚"")‚""""‚"")‚"src="‚"")
savepic=url
end function
Function RegExp_Execute(patrn‚ strng)
Dim regEx‚ Match‚ Matches‚values '建立变量。
Set regEx = New RegExp '建立正则表达式。
regEx.Pattern = patrn '设置模式。
regEx.IgnoreCase = true '设置是否区分字符大小写。
regEx.Global = True '设置全局可用性。
Set Matches = regEx.Execute(strng) '执行搜索。
For Each Match in Matches '遍历匹配集合。
values=values&Match.Value&"‚"
Next
RegExp_Execute = values
End Function
  • 打赏
  • 举报
回复
Set objRegExp = New Regexp'设置配置对象 
objRegExp.IgnoreCase = True'忽略大小写
objRegExp.Global = True'设置为全文搜索
objRegExp.Pattern = "<img.+?>"
strs=trim(str)
Set Matches =objRegExp.Execute(strs)'开始执行配置
For Each Match in Matches
RetStr = RetStr &getimgs( Match.value )'执行第二轮的匹配
Next
function getimgs(str)
getimgs=""
Set objRegExp1 = New Regexp
objRegExp1.IgnoreCase = True
objRegExp1.Global = True
objRegExp1.Pattern = "http://.+?";""'取出里面的地址
set mm=objRegExp1.Execute(str)
For Each Match1 in mm
getimgs=getimgs&"
"&left(Match1.value,len(Match1.value)-1)'把里面的地址串起来备用
next
end function
这是一个方式

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧