NYCPHP Meetup

NYPHP.org

[nycphp-talk] regex for removing all newlines, line feeds

Andrew Yochum andrew at digitalpulp.com
Tue Oct 12 17:19:45 EDT 2004


On Tue, Oct 12, 2004 at 03:38:20PM -0400, William Briggs wrote:
> 
> I'm looking for a regular expression that matches all newlines, tabs, 
> and line feeds.  The only one I've got so far is '/[[:space:]]/' which 
> works, but also removes the spaces which I want to keep.
> 
> I know '\r' and '\n' are the right seed but I can't seem to get them to 
> work through the string (which make contain many newlines and line feeds).

I usually use something along the lines of:
    /(\r\n|\r|\n)/
which catches all variations (Unix, Mac, Windows).

HTH,
Andrew



More information about the talk mailing list