in reply to Replacing new line characters from HTML TEXTAREA submissions

Are you perhaps on a Windows machine? If so, you have dealt with the \n in each end-of-line \r\n pair, but you have left the \r behind. So the lines are over-laying each other. I submit that what you actually have as the result of your SELECT query is (ignore the fact that I am showing this on separate lines; you have gotten rid of the \n's but it helps to show how things line up.):
Hello,\r <p>\r <p>This is a test.\r <p>\r <p>Bye Bye.
At the end of each line, the \r, is just moving the cursor back to the beginning of the line and writing the next line right over the top of the previous one. Smash each of those lines right over the top of the previous line and by the time you get to the end, you have:    <p>Bye Bye.a test. Once you see that, you are probably clear that your regex should be:    $info =~ s/\r\n/<p>/g; Hope that helps. (Actually, you probably didn't need anything past the heads-up in the first line or two of this post.) And if you are not on Windows, then I don't have a clue! ;-) MSgremlins, perhaps...

Replies are listed 'Best First'.
Re: Re: Replacing new line characters from HTML TEXTAREA submissions
by Anonymous Monk on Mar 16, 2001 at 15:32 UTC

    Thankyou!

    I changed my code to read

    $info =~ s/(\r?\n)+/<p>/g;

    and now it works (and catches blank lines too).

    --
    The Original Posting Monk