大家好,我还在努力理解preg_match_all,我的多动症大脑尚未看到模式。我有一个包含网页内容的变量。如何抓取所有带有nnnn的链接?谢谢,Rick
F feedsrewestkind1972 New member 2021-12-31 #1 大家好,我还在努力理解preg_match_all,我的多动症大脑尚未看到模式。我有一个包含网页内容的变量。如何抓取所有带有nnnn的链接?谢谢,Rick
I inwonranu1971 New member 2021-12-31 #4 我让这个函数工作了。如何编辑它,以便我只获取其中包含“ nnnn”的url? function getUrls($string){ $ regex ='/ https?:/ / [^" ] / i'; preg_match_all($regex,$ string,$ matches); return($ matches [0]);} // $ urls = getUrls($ string); // print_r($ urls);
我让这个函数工作了。如何编辑它,以便我只获取其中包含“ nnnn”的url? function getUrls($string){ $ regex ='/ https?:/ / [^" ] / i'; preg_match_all($regex,$ string,$ matches); return($ matches [0]);} // $ urls = getUrls($ string); // print_r($ urls);
T tudewitgai1970 New member 2021-12-31 #5 不要再使用preg_match了。http://php.net/manual/en/class.domxpath.php DOM XPath正是用于这个目的而建的。