NYCPHP Meetup

NYPHP.org

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

David Mintz dmintz at davidmintz.org
Tue Oct 12 17:21:32 EDT 2004


On Tue, 12 Oct 2004, 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 ~should~ reply off-list because I'm a mere demi-geek and tired of
publicly embarrassing myself, but <sigh /> .....

You might be able to use str_replace():

    $find = array(chr(10),"\n","\t");
    $replace = '';
    $string = str_replace($find,$replace,$string);

	David

---
David Mintz
http://davidmintz.org/

        "Anybody else got a problem with Webistics?" -- Sopranos 24:17



More information about the talk mailing list