Re: Quick regular expressions question / preg_replace
| From: | David Yee | Date: | Sat, 05 Jan 2002 03:05:30 +0000 |
| Subject: | Re: Quick regular expressions question / preg_replace | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-79525@lists.php.net to get a copy of this message | ||
Ah that would do it (just need to double quote the \r\n). Thanks! I just
know, however, one of these days I'm gonna need to use preg_replace :-).
David
----- Original Message -----
From: "Bogdan Stancescu" <mgv@fx.ro>
To: "David Yee" <david@coolcomputing.com>
Cc: <php-general@lists.php.net>
Sent: Friday, January 04, 2002 6:46 PM
Subject: Re: [PHP] Quick regular expressions question / preg_replace
> str_replace("\r\n<html>\r\n", '\r\n', $string);
>
> David Yee wrote:
>
> > That's an idea but it would delete the carriage return before it which I
> > don't want to happen. I've tried preg_replace("/^<html>\r\n/",
> > '',
$string)
> > + quite a few other variations but no luck :-(. Argh!
> >
> > David
> >
> > ----- Original Message -----
> > From: "Bogdan Stancescu" <mgv@fx.ro>
> > To: "David Yee" <david@coolcomputing.com>
> > Cc: <php-general@lists.php.net>
> > Sent: Friday, January 04, 2002 6:20 PM
> > Subject: Re: [PHP] Quick regular expressions question / preg_replace
> >
> > > I suck big time at regular expressions, but have you tried
> > > str_replace("\r\n<html>\r\n", '', $string); ?
> > >
> > > Bogdan
> > >
> > > David Yee wrote:
> > >
> > > > Hi guys. Quick regular expressions question here:
> > > >
> > > > I want to match:
> > > >
> > > > <html>
> > > >
> > > > but not:
> > > >
> > > > blah blah <html>
> > > >
> > > > Basically I want to wipe out lines beginning with the <html> tag
> > followed
> > > > immediately by a carriage return. If I do a:
> > > >
> > > > str_replace("<html>\r\n", '', $string);
> > > >
> > > > It wipes out <html> and the carriage return after blah blah <html>.
So
> > I
> > > > suppose I have to turn to preg_replace, but I'm having a hard time
> > coming up
> > > > with the right pattern. Thanks.
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > > For additional commands, e-mail: php-general-help@lists.php.net
> > > To contact the list administrators, e-mail:
php-list-admin@lists.php.net
> > >
> > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>