Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove <br /> from inside <pre> </pre> tag

I made simple BBCode script and it works all fine. But then later i use a javascript library to beautify my codes in <pre></pre>.

Now the only problem I am facing that I have <br /> tags after each line of code in <pre></pre> tags.

So the question is how could I remove the <br /> tags which ARE INSIDE the <pre></pre> tags only.

A regex with preg_replace seems to be the thing i need but I could not find/make one to match my need. I not much good with regex. :S

like image 366
cjmling Avatar asked Nov 20 '25 06:11

cjmling


1 Answers

Could u provide us an example of the code u want to test please.

Pattern should looks like : '/.*<pre>.*(<br \/>).*<\/pre>/'

Here is the link of my try : https://regex101.com/r/pV2qX8/2

NOTE : u can reverse the capturing braces - It was just to show u it catched only the <br /> inside <pre></pre>.

NOTE 2 : About sub-question u can find the answer : here

(Sub-Q : multiple <br /> instances with condition)

like image 142
Falt4rm Avatar answered Nov 21 '25 20:11

Falt4rm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!