Home > Article > Backend Development > 求一正则
$str = "图片1:<img src='1.jpg' alt="求一正则" >,图片2:<img src=\"2.jpg\" alt="求一正则" >";
$str = "图片1:<img src='1.jpg' alt="求一正则" >,图片2:<img src=\"2.jpg\" alt="求一正则" >";preg_match_all('/src=([\'"])(.+)\1/isU', $str, $m);print_r($m);
Array( [0] => Array ( [0] => src='1.jpg' [1] => src="2.jpg" ) [1] => Array ( [0] => ' [1] => " ) [2] => Array ( [0] => 1.jpg [1] => 2.jpg ))
一定要把单引号、双引号也匹配出来吗?
那就不明白你在想什么了
好吧,多谢老徐回答。