天天看點

從資料庫中提取圖檔位址

如資料庫content字段存儲的内容為:

"<P align=center><IMG style=""WIDTH: 193px; HEIGHT: 175px"" height=285 src=""http://localhost/xun/edit/UploadFile/201074211239952.gif"" width=337 border=0></P>

<P>&nbsp;&nbsp;&nbsp;氣象局4日釋出暴雨重要天氣預報:預計從4日下午到5日夜間,我區有一次暴雨天氣,并伴有強雷暴,請做好防範工作。</P>

<P>&nbsp;</P>"

現在要把這段内容的圖檔位址提取出來:

SourceCode=rs("content")

mypic=""

Set objRegExp = New Regexp

objRegExp.IgnoreCase = True

objRegExp.Global = True

objRegExp.Pattern = "<IMG src.+?border=0>"

strs=trim(SourceCode)

Set Matches =objRegExp.Execute(strs)

For Each Match in Matches

mypic =mypic& Match.Value

Next

mypic裡面就是所有的圖檔位址了

這兒提取出來的内容就是:

<IMG style=""WIDTH: 193px; HEIGHT: 175px"" height=285 src=""http://localhost/xun/edit/UploadFile/201074211239952.gif"" width=337 border=0>

如果隻想提取圖檔名稱:

SourceCode=rs("content")

mypic=""

Set objRegExp = New Regexp

objRegExp.IgnoreCase = True

objRegExp.Global = True

objRegExp.Pattern = "UploadFile/.+?>"

strs=trim(SourceCode)

Set Matches =objRegExp.Execute(strs)

For Each Match in Matches

temppic=Match.Value

temppic=split(temppic,"/")(1)

temppic=trim(split(temppic,"""")(0))

mypic =mypic&temppic

temppic=""

Next

現在提取出來的内容就是:

201074211239952.gif