Home >Backend Development >PHP Tutorial >一个正则有关问题求解

一个正则有关问题求解

WBOY
WBOYOriginal
2016-06-13 11:56:131065browse

一个正则问题求解
我的正则是这样的"",我想取页面中文字中的文字却又不想取一个正则有关问题求解 >这种格式的,我的正则该如何写,求大神指点。
------解决方案--------------------

preg_match('#<a>(.+?)</a>#',$s,$m);<br />echo $m[1];

------解决方案--------------------
$str = "<a><img  alt="一个正则有关问题求解" ></img >文字</a>";<br />$sr = strip_tags($str,'<a>');<br />var_dump($sr);

------解决方案--------------------
<br />$test = "<a class='123'>test</a><a href='/ss'><img  src='aa.jpg'/ alt="一个正则有关问题求解" ></a><a>123</a>";<br />$s = "#<a[^>]*>[^<]*<\/a>#";<br />preg_match_all($s,$test,$res);<br />print_r($res);<br />

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