请求帮助

crospo 2009-12-22 10:50:34
<DIV><IMG alt=侯医生团队 src="http://www.houyisheng.com/e/UploadFile/2009317131345635.jpg" border=0></DIV>

<P align=center><IMG src="http://www.houyisheng.com/e/UploadFile/200858105244831.jpg" border=0></P>

<P><FONT face=Verdana><BR>侯医生又一专利技术使央视主持重返荧幕  <BR> </FONT></P>

以上是数据库存有的3条数据

有点问题 :1.我现在在页面把这数据完全显示出来 也就是
<DIV><IMG alt=侯医生团队 src="http://www.houyisheng.com/e/UploadFile/2009317131345635.jpg" border=0></DIV>

<P align=center><IMG src="http://www.houyisheng.com/e/UploadFile/200858105244831.jpg" border=0></P>

<P><FONT face=Verdana><BR>侯医生又一专利技术使央视主持重返荧幕  <BR> </FONT></P>
这样格式
2. 我想把里面图片的名称提取出来 2009317131345635.jpg ,200858105244831.jpg
...全文
112 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yan11cn 2009-12-27
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 crospo 的回复:]
strimg输出的: 他方埃弗顿按时打算的阿斯顿按时打算的爱仕达阿斯顿啊啊速度阿斯顿阿斯顿 <IMG style="WIDTH: 500px; HEIGHT: 375px" src="http://www.houyisheng.com/admin/Edit/uploadfile/2009122561356805.JPG"> <BR> </P>  请问如何得到2009122561356805.JPG 这个名字
正则表达式 我不熟悉 请指教
[/Quote]

<%
dim str,reg
set reg = New RegExp
reg.Global=true
reg.Pattern="(\d+(\.jpg|.JPG))"
reg.IgnoreCase = false
str="<DIV> <IMG alt=侯医生团队src=""http://www.houyisheng.com/e/UploadFile/2009317131345635.JPG""border=0></DIV>"
str=trim(str)
set colMatches = reg.Execute(str)
for each match in colMatches
response.write(match.value&"<br />")
next
%>
crospo 2009-12-27
  • 打赏
  • 举报
回复
<%
function changepic(pics)
Set re = New RegExp
re.Pattern = "(.*?)\B\/(\S+)(\.jpg|.gif|.png|.bmp)[""][^""]+"
re.Global = True
re.IgnoreCase = True
re.MultiLine = True
rv = re.Replace(pics,"$1$2")
changepic = rv
end function

Set Rs = Conn.Execute("Select Top 1 * From NewsCont where CID =1 order by Times desc,Times desc")
str = server.htmlencode(rs("content"))
strimg= changepic(str)
response.write strimg

%>

我用楼上的朋友代码做了下 但是情况还是不怎好 继续请教

strimg输出的: 他方埃弗顿按时打算的阿斯顿按时打算的爱仕达阿斯顿啊啊速度阿斯顿阿斯顿<IMG style="WIDTH: 500px; HEIGHT: 375px" src="http://www.houyisheng.com/admin/Edit/uploadfile/2009122561356805.JPG"><BR></P> 请问如何得到2009122561356805.JPG 这个名字
正则表达式 我不熟悉 请指教
  • 打赏
  • 举报
回复
使用正则就可以取到
function changepic(pics)
Set re = New RegExp
re.Pattern = "(.*?)\B\/(\S+)(\.jpg|.gif|.png|.bmp)[""][^""]+"
re.Global = True
re.IgnoreCase = True
re.MultiLine = True
rv = re.Replace(pics,"$1$2")
changepic = rv
end function

举一个例子
yan11cn 2009-12-22
  • 打赏
  • 举报
回复
正则表达式提取:用之前只需要从数据库中取出来用replace函数把"替换成'就行了
如:

<%
dim str,reg
set reg = New RegExp
reg.Global=true
reg.Pattern="(\d+\.jpg)"
reg.IgnoreCase = false
str="<DIV> <IMG alt=侯医生团队src='http://www.houyisheng.com/e/UploadFile/2009317131345635.jpg' border=0></DIV>"
str=trim(str)
set colMatches = reg.Execute(str)
for each match in colMatches
response.write(match.value&"<br />")
next
%>
gxq323 2009-12-22
  • 打赏
  • 举报
回复
<%
function GetImgFromContent(html)
Dim Re, match, matchs, htm, t
htm = ""
set Re = new RegExp
re.IgnoreCase =True
re.Global = True
re.Pattern = "<img [^<]*src=""(.*)""[^>]*>"
Set matchs = re.Execute(html)
for each match in matchs
htm = htm + (match.SubMatches(0)) & "|$|"
next
if htm="" then
GetImgFromContent="img/W020091010368958908816.jpg"
else
set matchs = nothing
t = split(htm, "|$|")

if len(t) = 0 or t = "" then
GetImgFromContent=""
end if

GetImgFromContent =t
end if
end function
%>返回是数组,自己改改
supermass 2009-12-22
  • 打赏
  • 举报
回复
通过字符串搜索来做吧。
crospo 2009-12-22
  • 打赏
  • 举报
回复
首先谢谢大家 但是我还有点不明白

我的content中的数据是<P> <FONT face=Verdana> <BR>侯医生又一专利技术使央视主持重返荧幕   <BR>  </FONT> </P>

当我response.write rs("content") 时候

得到结果不是我想要
我想得到结果是
<P> <FONT face=Verdana> <BR>侯医生又一专利技术使央视主持重返荧幕   <BR>  </FONT> </P>

28,406

社区成员

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

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