in reply to Re: Regular Expression Elegance
in thread Regular Expression Elegance

you're opening a can of worms here . . . legacy code is the short answer!

user input is saved from a multi-line textbox to a db. To display the text, carrige returns are handled by this:
$value =~ s/\n/<br>/g;
recently code has been added to allow hyperlinks to be inputed by users, using custom tags handled by another reg expresion. If a typed link is longer than the multi-line textbox width, it will wrap and thanks to the above reg expresion will contain a <b> which breaks the link.
now you know . . .

Replies are listed 'Best First'.
Re^3: Regular Expression Elegance
by JadeNB (Chaplain) on Nov 11, 2008 at 16:28 UTC
    I guess that it's not possible to get at the $value before the <br>-substitution—maybe making a copy of it, so that you don't stomp on the display manipulations—and perform the substitution $value =~ s/\n//g on it instead?
      yes I can but then I would still need to remove the newline chars from within the my tags but then at least it would never contain the <b> tags.