Home > Backend Development > PHP Tutorial > 正则有关问题求教

正则有关问题求教

WBOY
Release: 2016-06-13 13:26:49
Original
764 people have browsed it

正则问题求教
我想把字符串中的title内容找出来,该怎么弄?下面code是我写得,但不行..

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php $regex='/<title>[\s\S]*?/';
$str='aaa<title>bbbbbb</title>ccccccccc';
$result=array();
preg_match($regex,$str,$result);
print_r($result);
?>

Copy after login


------解决方案--------------------
$regex='/([\s\S]*?)/'; <br><font color="#e78608">------解决方案--------------------</font><br>$regex='/<title>.*?/'; <div class="clear"> </div>
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