Home > Backend Development > PHP Tutorial > java regular expression PHP extracts the image address in the string [regular expression]

java regular expression PHP extracts the image address in the string [regular expression]

WBOY
Release: 2016-07-29 08:47:18
Original
1158 people have browsed it

Copy code The code is as follows:


$str='

';
$pattern="/<[img|IMG].*?src=['|"](.*?(?:[.gif|.jpg])) ['|"].*?[/]?>/";
preg_match_all($pattern,$str,$match);
print_r($match);
?>


The result shows:
Array
(
[0] => Array
(
[0] =>
)
[ 1] => Array
(
[0] => upfiles/2009/07/1246430143_1.jpg
)
)

The above introduces the java regular expression PHP to extract the image address in the string [regular expression], including the content of java regular expression. I hope it will be helpful to friends who are interested in PHP tutorials.

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