"Curt Zirzow" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> * Thus wrote David Sklar ([EMAIL PROTECTED]):
> > I was thinking about adding one or two regex-related features to the
engine:
> >
> > 1. "preg_case": this would behave just like case but instead of doing an
> > equality comparison, would match against a regular expression, e.g.
> >
> > switch($data) {
> >    preg_case '/^\d{5}(-\d{4})?$/':
> >        print "US Postal Code";
> >        break;
> >    preg_case '/^[a-z]\d[a-z] ?\d[a-z]\d$/i';
> >        print "Canadian Postal Code";
> >        break;
> >    default:
> >        print "something else!";
> > }
> [...]
> >
> > Some issues with adding these features:
> >
> > - It creates an engine dependency on the PCRE library.
> > - There would have to be some new opcodes and parser tokens
> > - Ideally the code that implements these operators could share as much
as
> > possible with what's already been done in the PCRE extension -- is that
> > possible?
>
> I'm thinking a more viable solution would be to do something like:
>
> mixed preg_match ( mixed pattern, string subject [, array matches [, int
flags]])
>
> if pattern is an array, preg_match will cycle through each one till
> a match is made; returns the index of the array passed (that
> matched) or false if not found.

It's the same if you have the array with patterns and you make a simple
foreach() cycle. I don't think that functions with internal loops should be
created, when we have a clear solution without it.

>
> This should also be BC if you just pass one string.
>
>
> Curt
> --
> "I used to think I was indecisive, but now I'm not so sure."

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to