'; $pattern="/<[img|IMG].*?src=['|"](.*?(?:[. gif|.jpg]))['|"].*?[/]?>/"; p"/>

'; $pattern="/<[img|IMG].*?src=['|"](.*?(?:[. gif|.jpg]))['|"].*?[/]?>/"; p">

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
WBOYOriginal
2016-07-29 08:47:181159browse

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.

Statement:
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