Home > php教程 > PHP源码 > body text

Create a regular expression that matches images on web pages

WBOY
Release: 2016-07-06 13:28:32
Original
1393 people have browsed it
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 "网页图片格式错误";	
}
?>
Copy after login
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template