注册 登录
编程论坛 ASP技术论坛

求助:截取字符串

y2000sc 发布于 2008-04-29 20:55, 461 次点击
从数据库中获取concent内容截取里面的第一个图片链接

content数据
<p>sfsafsafsadfsdafsadfsdafsf</p>
<p>safsadfsafsafsdafsafsafsaf</p>
<p>sdafasfsafsdfa</p>
<p><img src="upload/a.jpg" width="600" height="109">
<img src="uploadfile/b.gif" width="600" height="109">
<img src="tt/c.gif" width="600" height="109"></p>

我想获取到upload/a.jpg,该如何实现呢?
谢谢!
3 回复
#2
multiple19022008-04-29 22:04
你试试Instr函数和Mid函数,比如
Dim Start,length
start=Instr(content,"src=""")    ' 注意和下面Instr用法的区分。两个双引号转义为一个双引号

length=Instr(start+4,Content,"""")    '这是Instr函数的另一种用法,第一个参数是从哪里开始找
看看值如何,start应该要加上偏移量
然后用
s=Mid(Content,START,LENGTH)得到
#3
hxfly2008-04-29 22:22
可以研究一下SPLIT
if ubound(split(content,"upload/"))>0 then
    s="upload/"&split(split(content,"upload/")(1),Chr(34))(0)
end if
如果比较规则的话,我还是喜欢用SPLIT
#4
feifeiaini12008-04-30 11:42
用正则表达式
1