开发者

Simple regular expression to get text between <br/> and next <br/>

开发者 https://www.devze.com 2023-01-09 12:24 出处:网络
I have a string that contains this (and another things): <b>SINOPSIS:</b><br/> Text text text and mooore text...<br/>

I have a string that contains this (and another things):

<b>SINOPSIS:</b><br/> 
Text text text and mooore text...<br/> 

I need a reg-ex to get the text between those first two <br/> tags.

Thanks...

Note: There are more <br/> tags. I need the 开发者_运维问答first occurrence only..

I will be using PHPs preg_match() function.


this will work, make sure to enable multiline

there are other fancier ways with more checks ect...

edit:

preg_match('!\<br\/\>.+?\<br\/\>!s', $string);

Example 2 (For whitespace before close br),

!\<br\s*/?>.+?\<br\s*/?>!s


Allow me to point you to this brilliant answer by bobince that I stumbled upon when I was tempted to ask a similar question: RegEx match open tags except XHTML self-contained tags

0

精彩评论

暂无评论...
验证码 换一张
取 消