Could someone please help me with the regexp javascript code to replace all <br /> tags with a newline "\n" character found within <pre> divisions.. For example, a string passed to the function containing the following:
<pre class="exampleclass">1<br />2<br />3</pre>
Should be returned as (newlines not shown, though I hope you get the idea):
<pre class="exampleclass">1(newline)2(newline)3</pre>
Another example:
<div>foo<br />bar<pre>1<br />2</pre></div>
Returned as:
<div>foo<br />bar<pre>1(newline)2</pre></div>
Note that the class and division content is dynamic, along with other content in the string (other divs etc). On the other hand, the <br /> tag does not change, so there's no need to cater for <br> or other variants.
NB - I'm working with strings, not HTML elements.. Just in case there is any confusion by the way I have presented the question.
pretags. So from your comment, it sounds as though you're saying another example string would be "<div>foo<br />bar<pre>1<br />2</pre></div>", with the expected result "<div>foo<br />bar<pre>1(newline)2</pre></div>". That completely changes the question.