in reply to The Mysteries Of LineBreaks

First off, what browser are you using to submit the form? What the browser sends, your script will receive, so it is probably that. Different browsers on different platforms sends different line breaks.

If you are having trouble with replacing two characters, you could for instance strip out all \r characters, either before replacing, or even before you are saving that input to file.

But probably the simplest approach is to do something like this (untested and ugly code):

s/(\r?\n){2}/<p>/g; s/\r?\n/<br>/g;
That is, replace occurances of an optional \r and a non-optional \n with first <p> for double matches, and then <br> for single ones left after the first pass.

Hope that helps.


You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.