求一正则

WBOY
Release: 2016-06-20 12:43:00
Original
795 people have browsed it

$str = "图片1:<img  src='1.jpg' alt="求一正则" >,图片2:<img  src=\"2.jpg\" alt="求一正则" >";
Copy after login


匹配出$str内src里面的内容的正则应该怎么写?


回复讨论(解决方案)

$str = "图片1:<img  src='1.jpg' alt="求一正则" >,图片2:<img  src=\"2.jpg\" alt="求一正则" >";preg_match_all('/src=([\'"])(.+)\1/isU', $str, $m);print_r($m);
Copy after login
Array(    [0] => Array        (            [0] => src='1.jpg'            [1] => src="2.jpg"        )    [1] => Array        (            [0] => '            [1] => "        )    [2] => Array        (            [0] => 1.jpg            [1] => 2.jpg        ))
Copy after login

一定要把单引号、双引号也匹配出来吗?

那就不明白你在想什么了

好吧,多谢老徐回答。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template