in reply to Re^2: Replace newlines only if not inside braces
in thread Replace newlines only if not inside braces
No, there is no difference. I just thought it would be a little bit more efficient. I thought that, if the \K is outside, the $& variable is being cleaned up for every substitution, which is not really necessary. It should be cleaned only when something on the left side has been matched. Anyway, it is more readable in your way, and does, basically, the same thing. :)
Alternatively, to work with strings that contain {{...}} groups, which are not followed by a newline, this code should do it:
Alternatively, to work with strings that contain {{...}} groups, which are not followed by a newline, this code should do it:
$data =~ s<(?:{{.*?}}|[^\n])*\K\n>{<br>\n}gs; print $data;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Replace newlines only if not inside braces
by LanX (Saint) on Feb 11, 2013 at 20:15 UTC | |
by trizen (Hermit) on Feb 11, 2013 at 21:47 UTC |
In Section
Seekers of Perl Wisdom