RE: [PHP-DEV] regex operators

From: Date: Tue, 14 Oct 2003 18:14:32 +0000
Subject: RE: [PHP-DEV] regex operators
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-4838@lists.php.net to get a copy of this message
On Tuesday, October 14, 2003 1:10 PM, mailto:rasmus@lerdorf.com wrote: > You are pushing towards > > $_~=/^\.*?\$$/; > > This is not human-readable code and one of the basic characteristics > that sets PHP apart from Perl. Actually, I'm pushing towards if (! ($_REQUEST['email'] =~ '/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i')) { $form->addError('Please enter a valid e-mail address.'); } There's not much we can practically do about the punctuation density of regular expressions, but we can make their use more widespread by changing the syntax of how they're invoked. > Every non-trivial line of PHP code > has a decypherable keyword that you can plug into the manual to > figure out what that line is doing. I think this is a great aspect of PHP. > We make sure of this by keeping > the number of operators to a minimum. As for your bitshifting > example. It has nothing to do with the frequency of use, it has to > do with readability. So why is the === operator an operator and not an is_identical() function? My motivation for this operator is to encourage regular expression use as part of the core toolbox of PHP programmers. I think, especially in a web context, where so much work has to do with data validation and manipulation, that this is a reasonable goal. The features that the preg_* functions provide are great -- I think we should explore ways to have an operator syntax for regular expressions. David

« previous php.internals (#4838) next »