in reply to (Regex Madness) And you thought whitespace was easy.

How about this one: \n\n is a paragraph break which stays such, but other whitespace is collapsed. So..

When we type text, we might leave more than one blank line, but that still indicates one paragraph break. Or the line might not be empty but have a space on it, etc.

So, a whitespace sequence that contains at least two \n characters is replaced by \n\n, and all other whitespace sequences are replaced by single space, and leading/training whitespace is thrown away.

—John

  • Comment on Re: (Regex Madness) And you thought whitespace was easy.