Home  >  Article  >  Backend Development  >  求一个php正则表达式

求一个php正则表达式

WBOY
WBOYOriginal
2016-06-06 20:48:531183browse

某段文字可能是

<code>/34-Cosplayer">Cosplayer<br>bala balab a la<br>
</code>

也可能是

<code>/34-Cosplayer">Cosplayer<br>bala ba la ba la
</code>

也就是前面可能有<br>也可能没有,如果用正则最小范围的同时匹配这两段内容(不能用.*?

回复内容:

某段文字可能是

<code>/34-Cosplayer">Cosplayer<br>bala balab a la<br>
</code>

也可能是

<code>/34-Cosplayer">Cosplayer<br>bala ba la ba la
</code>

也就是前面可能有<br>也可能没有,如果用正则最小范围的同时匹配这两段内容(不能用.*?

<code>/34-Cosplayer">Cosplayer<br>[^)?
</code>

大致是这样子。不太了解 PHP 正则的 flavor。

<code>$a = explode('/34-CosPlayer">CosPlayer', $html);
$b = explode('', $a[1]);
echo $b[0];
</code>

现在都不太想用正则解析了,直接用explode也挺方便的…话说用Pad敲代码实在是太不方便了…=_=

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