WEB开发网      婵犻潧鍊婚弲顐︽偟椤栨稓闄勯柦妯侯槸閻庤霉濠婂骸浜剧紒杈ㄥ笚閹峰懘鎮╅崹顐ゆ殸婵炴垶鎸撮崑鎾趁归悩鐑橆棄闁搞劌瀛╃粋宥夘敃閿濆柊锕傛煙鐎涙ê鐏f繝濠冨灴閹啴宕熼鍡╀紘婵炲濮惧Λ鍕叏閳哄懎绀夋繛鎴濈-楠炪垽鎮归崶褍妲婚柛銊ュ缁傚秹鏁撻敓锟� ---闂佹寧娲╅幏锟�
开发学院WEB开发ASP ASP如何获得代码中第一张图片地址 阅读

ASP如何获得代码中第一张图片地址

 2007-10-14 10:35:26 来源:WEB开发网 闂侀潧妫撮幏锟�闂佸憡鍨电换鎰版儍椤掑倵鍋撳☉娆嶄沪缂傚稄鎷�婵犫拃鍛粶闁靛洤娲ㄩ埀顒佺⊕閵囩偟绱為敓锟�闂侀潧妫撮幏锟�  闂佺ǹ绻楀▍鏇㈠极閻愭娑樷枎閹邦剛娉氶梺鍛婎殔濞层劌鈻撻幋婵愬殫妞ゆ梻鍘х憴锟�
核心提示:'把pattern 又修改了下'code要检测的代码'http://www.cncms.com/asp.asp'leixing html 或者ubb'nopic 代码没有图片时默认值function toppic(code,leixing,nopic) set regex =

'把pattern 又修改了下
'code要检测的代码
'http://www.cncms.com/asp.asp
'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=""http://www.cncms.com/1.gif"">"
pic = toppic(code1,"html","nopic.gif")
response.Write pic

Tags:ASP 如何 获得

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接