关于PHP中 preg_match_all 的问题
<a href="http://www.aaa.com/afdfdasfdasfa ccc">
<a href="http://www.bbb.com/agsdghasfsdfsa ccc">
<a href="http://www.ccc.com/fsdhdftgdasfgasf ccc">
aaa.com bbb.com
afdfdasfdasfa
这些地方是变化的
但是ccc不变请问用PHPpreg_match_all 怎么写正则取得所有的url
然后产生一个由各url组成的数组
谢谢~~~
<a href="http://www.aaa.com/afdfdasfdasfa ccc">
<a href="http://www.bbb.com/agsdghasfsdfsa ccc">
<a href="http://www.ccc.com/fsdhdftgdasfgasf ccc">
aaa.com bbb.com
afdfdasfdasfa
这些地方是变化的
但是ccc不变请问用PHPpreg_match_all 怎么写正则取得所有的url
然后产生一个由各url组成的数组
谢谢~~~
<a href="http://www.bbb.com/agsdghasfsdfsa ccc">
<a href="http://www.ccc.com/fsdhdftgdasfgasf ccc">';preg_match_all('|<a +href\s*=\s*"?(.+? +ccc)"?|is',$str,$matches);
print_r($matches);
<?php
$string = '<a href= "http://www.aaa.com/afdfdasfdasfa ccc"><a href="http://www.bbb.com/agsdghasfsdfsa ccc"><a href="http://www.ccc.com/fsdhdftgdasfgasf ccc">';
$pattern = '/http\:\/\/[\w]+.[\w]+.[\w]{2,}\/[\w|\s]+ccc/i';
preg_match_all($pattern,$string,$array);
print_r($array);
?>