PHP regular match specifies the beginning and end of the content & non-greedy mode

巴扎黑
Release: 2016-11-23 14:32:16
Original
2097 people have browsed it

php regular matches the specified start and end content, specifies the start and end position, extracts/matches the middle content, and returns the processed string content. Non-greedy mode is used

<?php
/**
 * create by tuzwu@qq.com for 小桔灯www.xiaojudeng.com
 */
$string=&#39;My String <span class="infolist"><a class="info" href="http://www.xiaojudeng.com/">小桔灯信息网
adfadf
adsf
fgsdfg
</a></span><span>分类信息</span>&#39;; 
$string = preg_replace(&#39;/(<span class="infolist">).*?(<\/span>)/is&#39;, &#39;&#39;, $string); 
echo $string;
?>
Copy after login


Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!