* Thus wrote Justin Patrin: > On Thu, 1 Jul 2004 16:41:50 -0500, Josh Close <[EMAIL PROTECTED]> 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! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php