Re: [Patch] Use str_replace instead of preg_replace in

From: Date: Mon, 20 Sep 2004 12:11:10 +0000
Subject: Re: [Patch] Use str_replace instead of preg_replace in
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-33484@lists.php.net to get a copy of this message
Hi Matthias Pigulla, you wrote: > 1. $data = preg_replace("/(?<!\r)\n|\r(?!\n)/", "\r\n", $data); > > 2. $data = str_replace(array("\n", "\r\r\n", "\r", > "\r\n\n"), "\r\n", $data); Doing some simple benchmarks shows that preg_replace provides nearly identical speed, while IIRC it operates even faster on large texts. And it seems that array('/(?<!\r)\n/','/\r(?!\n)/') is faster than '/(?<!\r)\n|\r(?!\n)/'. Cheers, -- Michael - < mike(@)php.net >

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.pear.dev (#33484) next »