Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45806 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63870 invoked from network); 13 Oct 2009 22:01:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Oct 2009 22:01:16 -0000 Authentication-Results: pb1.pair.com header.from=adam@trachtenberg.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=adam@trachtenberg.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain trachtenberg.com from 216.93.242.2 cause and error) X-PHP-List-Original-Sender: adam@trachtenberg.com X-Host-Fingerprint: 216.93.242.2 miranda.org Received: from [216.93.242.2] ([216.93.242.2:42498] helo=miranda.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 52/32-49472-AA8F4DA4 for ; Tue, 13 Oct 2009 18:01:15 -0400 Received: (qmail 31388 invoked by uid 546); 13 Oct 2009 18:01:11 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 13 Oct 2009 18:01:11 -0400 Date: Tue, 13 Oct 2009 18:01:11 -0400 (EDT) X-X-Sender: adam@miranda.org To: "jvalade@eoni.com" cc: internals@lists.php.net In-Reply-To: <1c00dc04f55e49e38efc94aa7204c53a.jvalade@eoni.com> Message-ID: References: <1c00dc04f55e49e38efc94aa7204c53a.jvalade@eoni.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Subject: Re: [PHP-DEV] Why is ereg being deprecated? From: adam@trachtenberg.com (Adam Maccabee Trachtenberg) > On Mon, 12 Oct 2009, jvalade@eoni.com wrote: >> Mark Krenz wrote: >> 7. PHP Cookbook from 2006 >> Has mixed examples, some using ereg and some using preg_match > In PHP Cookbook, the only use of ereg I found was in the section > where the books was explaining how to convert from ereg to > preg_match. Or an occasional mention that said you could do it with > ereg but preg_match was better. But, I might have missed something. No. You are correct. We switched over all the examples to preg when we revised the book for the second edition. As we said in the introduction to our Regular Expressions chapter: "In general, there's no longer any reason to use the ereg functions." We also included a Recipe for converting from ereg to preg, including how to use addcslashes() to escape your delimiter, and dechex() when you're using an integer instead of a string as an input value for a pattern or replacement (a valid, and highly useful case in some instances, but very esoteric for most programs). So, yes, there is some work that needs to be done to upgrade scripts, and, yes, there are some dank corner cases, but they are relatively straight forward to go after, shed light on, and clean up. As someone who had to convert legacy code from PHP/FI to PHP 3, when PHP changed its string contactenation operator, of all things, I can say that subbing ereg() for preg() is an easier transition, especially when it has the value of letting PHP 6 seamlessly support Unicode. -adam -- adam@trachtenberg.com | http://www.trachtenberg.com author of o'reilly's "upgrading to php 5" and "php cookbook" avoid the holiday rush, buy your copies today!