in reply to Regex substituion eating newlines

Get rid of the "|$" portion. That matches the end of line, and the newline is whitespace at the end of a line. Or, if you do want spaces (but not newline) removed, don't use \s. Use a literal space character in your regex. Or [ \t] to match space and tab. Whatever you want to match.

tlm correctly pointed out to me that there's more to the replacement than whitespace, so getting rid of |$ will prevent a desired replacement.


Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Regex substituion eating newlines
by mdi (Acolyte) on May 10, 2005 at 12:08 UTC
    Thanks. I didn't realize newlines were considered whitespace.