May I ask questions about preg_match?

Source: Internet
Author: User
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='

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.