Home >php教程 >PHP源码 >Create a regular expression that matches images on web pages

Create a regular expression that matches images on web pages

WBOY
WBOYOriginal
2016-07-06 13:28:321414browse
Jump to [1] [Full screen preview]
<?php
$str="<img src='1.jpg' width='100px' height='200px' />";
$pattern="/^<img\s+src=.*?\/>$/i";
if(preg_match($pattern, $str)){
	echo "网页图片格式正确";
}else{
	echo "网页图片格式错误";	
}
?>
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