当前位置: 代码迷 >> ASP >> 提取路径,该怎么处理
  详细解决方案

提取路径,该怎么处理

热度:336   发布时间:2012-02-04 15:43:08.0
提取路径
<P   align=left> <IMG   style= "WIDTH:   156px;   HEIGHT:   119px "   height=599   src= "/DataBase/mypiczw/2007521152946486.jpg "   width=800   border=0> asdfsdfasdfasdfasdfasdf </P>

这段在数据库存的代码
我想把图的路径取出来有这个函数吗

------解决方案--------------------
正则,或者给img一个id后放到某个div中再getElementById()去取src~
------解决方案--------------------
<textarea id=textarea1>
<P align=left> <IMG style= "WIDTH: 156px; HEIGHT: 119px " height=599 src= "/DataBase/mypiczw/2007521152946486.jpg " width=800 border=0> asdfsdfasdfasdfasdfasdf </P>

</textarea>

<script language=vbs>
alert(aaa(textarea1.value))
function aaa(x)
dim re,mmm,m,i
set re = new RegExp
re.Pattern = "src= " "[^ " "]* " " "
re.Global = true
re.IgnoreCase = true
set mmm = re.execute(x)
for each m in mmm
i = i + 1
aaa = aaa & m & vbcrlf
aaa=replace(aaa, "src= ", " ")
aaa=replace(aaa, " " " ", " ")
next
set re =nothing
end function

</script>

简单匹配提取,
  相关解决方案