in reply to Re: Replacing line returns with br
in thread Replacing line returns with br

Correct me if I'm wrong, but wont this just replace the first occurrence of \n...I think we need to have the global modifier symbol ('g') at the end of the regexp :
$text =~ s/\n/<br>/g;

Replies are listed 'Best First'.
Re: Re: Re: Replacing line returns with br
by MrEgo (Initiate) on Jan 09, 2002 at 01:06 UTC
    > $text =~ s/\n/<br>/g;
    This is the expression I use as well. Replacing just the \n assures it works well even if there are no \r around (Unix environment). If there are (Windoze or MAC) I think they can just stay there, but one could get rid of them using:
    $text =~ s/\r//g;