- or download this
#!/usr/bin/perl
use strict;
use warnings;
...
1 while $text =~ s{^((?:(?!<pre>).|<pre>(?:(?!</pre>).)*</pre>)*?)\n}{
+$1<br/>}is;
print $text;
- or download this
<p>This is a line<br/>with a break.</p><pre>This is a pre
with a break.</pre><p>This is a line<br/>with a break.</p><br/>
- or download this
The regular expression:
(?is-mx:^((?:(?!<pre>).|<pre>(?:(?!</pre>).)*</pre>)*?)\n)
...
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------