'把pattern 又修改了下
'code要檢測的代碼
'http://www.devdao.com
'leixing Html 或者ubb
'nopic 代碼沒有圖片時默認值
function toppic(code,leixing,nopic)
set regex = new regexp
regex.ignorecase = true
regex.global = true
if leixing = "Html" then
regex.pattern = "<img(.*?)src\s?\=\s?(\u0022?)([^\u0022\/>]+)"
else
regex.pattern = "\[img\]([^\u005B]+)“
end if
set matches = regex.execute(code)
if regex.test(code) then
if leixing = "Html" then
toppic = matches(0).submatches(3)
else
toppic = matches(0).submatches(0)
end if
else
toppic = nopic
end if
end function
code1 = "<img src=""" ?>?
pic = toppic(code1,"Html","nopic.gif")
response.Write pic