in reply to Re: regex to replace linefeeds with <p> tags
in thread regex to replace linefeeds with <p> tags

Pasting from Windows environments will introduce \r\n because that's what Microsoft uses for linebreaks. It won't introduce \n\r or \r\r.

You don't want to introduce a <p> from a single <RETURN>, right? \r?\n is what you want to match.

If it's clearer to you, go ahead and remove all the \r in one pass and then handle the \n. Don't worry about efficiency here — you're doing IO!. The number of CPU cycles it takes to get a response from the keyboard to the CPU is enormous in comparison to the cycles to do a string replace.

throop