Re: regex problem

From: Date: Thu, 01 Jul 2004 23:21:40 +0000
Subject: Re: regex problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-189497@lists.php.net to get a copy of this message
* Thus wrote Justin Patrin: > On Thu, 1 Jul 2004 16:41:50 -0500, Josh Close <narshe@gmail.com> wrote: > > > > I'm trying to get a simple regex to work. Here is the test script I have. > > > > #!/usr/bin/php -q > > <? > > > > $string = "hello\nworld\n"; > > $string = preg_replace("/[^\r]\n/i","\r\n",$string); > > $string = preg_replace("/([^\r])\n/i","\\1\r\n",$string); > > You could also use forward look-aheads, but I don't remember how to do > that right now. actually look-behind: preg_replace("/(?<!\r)\n/", "\r\n", $string); Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid!

« previous php.general (#189497) next »