RE: [PHP-DEV] regex operators

From: Date: Tue, 14 Oct 2003 18:20:39 +0000
Subject: RE: [PHP-DEV] regex operators
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-4841@lists.php.net to get a copy of this message
On Tue, 14 Oct 2003, David Sklar wrote: > 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. And why in the world would we want to do that? I think you are completely missing the point here. > 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. I would like to encourage less usage of regular expressions by encouraging people to use very targeted and fast string manipulation functions. I know how most of the core guys feel on this one, and trust me, there is no chance this will get implemented. A bunch of us would put up a very strong veto. -Rasmus

« previous php.internals (#4841) next »