Regular expression match to match this format with regular expression & lt; LI & gt; & lt; A & nbsp; href = "http://news.17173.com/" & nbsp; target = _ blank & gt; news Center & lt;/A & gt; & nbsp; & lt ;? Php & nbsp regular expression matching
You want to use a regular expression to match this format.
News Center
$con= file_get_contents("http://17173.com");
$preg = '#
(.*)#';
preg_match_all($preg, $con, $arr);
//print_r($arr[1]);
foreach($arr[1] as $id=>$v){
echo "".$v." ".$arr[2][$id]."
";
}
?>
There is no matching result, but there is a link in this format on this page.
------ Solution --------------------
First, target = "_ blank" does not match the one given above. which one is it?
Then echo $ con.
Determine expected content
Pay attention to the case sensitivity and line feed issues-your regular expression is fixed with case sensitivity, and the dot does not contain line breaks.
------ Solution --------------------
Preg_match_all ('/
(.*?) <\/A>/I ', $ str, $ matches );
Var_dump ($ matches [1]);
Your problem is that the content of your website is like target = _ blank, but your target = "_ blank" is like this. if you have more quotation marks, you cannot match them.