views:

58

answers:

2

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.

+1  A: 

this will work, make sure to enable multiline

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

edit:

preg_match('!\<br\/\>.+?\<br\/\>!s', $string);
Viper_Sb
Not working. its getting the second pairs of br tags... Or maybe is a multi line problem. How to enable multi line?
Jonathan
it shouldn't be, can you post more of what you're matching against? as it should be limiting to the FIRST <br/> and second then stop.
Viper_Sb
Like I said, its maybe a multi line problem. How to enable multi line?
Jonathan
my bad I put the wrong option in I edited my answer try that one
Viper_Sb
Thanks working good!
Jonathan
final version is there in case it helps, I removed the allowance for whitespaces in the <br /> if you want those it can be done just more complicated
Viper_Sb
A: 

Allow me to point you to this brilliant answer by bobince that I stumbled upon when I was tempted to ask a similar question: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

KSwift87