For more information about preg_match, see how to capture a page and match all the links on the page with JavaScript code. Currently, I am using PHPcodefunctiongetLink ($ code) {preg_match_all (& quot;/src = [\ '\ & quot;] to ask about preg_match.
I would like to ask you how to capture a page and match all the links on the page with JavaScript. I am doing this now
PHP code
function getLink($code){ preg_match_all("/src=[\'\"]{0,1}([^>\'\"]*).*js/i"),$code,$link); return $link[1];}
However, when calling the page, the js link of the page is as follows, and the output is abnormal.
Http://www.test.com/1.js? EGo
----- This can only output http://www.test.com/1.
Http://www.test.com/2.js
----- This can normally output http://www.test.com/2.js
Please advise
------ Solution --------------------
Preg_match_all ("/src = [\ '\"] {0, 1} ([^> \' \ "] *. * js ?) /I "), $ code, $ link); // What about this?
------ Solution --------------------
Preg_match_all ("/src = [\ '\"] {0, 1} ([^> \' \ "] *. * js)/iU", $ code, $ link );
The result contains the mre_src part. if you do not want it
Preg_match_all ("/\ bsrc = [\ '\"] {0, 1} ([^> \' \ "] *. * js)/iU ", $ s, $ link );
------ Solution --------------------
PHP code
$str='