Re: Regular Expressions?
| From: | Jason Caldwell | Date: | Fri, 20 Apr 2001 17:03:02 +0000 |
| Subject: | Re: Regular Expressions? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49585@lists.php.net to get a copy of this message | ||
Ahh.... It makes more sense now.
Thanks.
Jason
"Brian Clark" <brianj@fusionwerks.com> wrote in message
news:190208283290.20010420031324@fusionwerks.com...
> Hi Jason,
>
> @ 3:08:06 AM on 4/20/2001, Jason Caldwell wrote:
>
> > Sorry if I seem dense. Your answer (although probably right on target)
> > leaves me still confused :-)
>
> No problem at all.
>
> > The example you gave me:
>
> > $string = 'aaaa.aaaa';
> > print(eregi("^([[:alnum:]]+\.[[:alnum:]]+)", $string) ? 'matched' :
> > 'no
> > match');
>
> > Now with your example (above) the following MATCHED (when, I think it
> > shouldn't have:)
>
> > (example 1)
> > aaaa.a!
>
> Matches because there is *at least* one alnum after the \.
> It doesn't care about the ! as long as it found the a.
>
> > aaaa.a#$%
>
> Ditto here.
>
> > aaaa.a23!%
>
> Ditto here.
>
> > The following did NOT match.
>
> > (example 2)
> > a!.aaaa
>
> This didnt' match because of ^[[:alnum:]]+\.
>
> There's a [:punct:] between the [:alnum:] and the \.
>
> > a%!.aaaa
>
> Ditto here.
>
> > aaaa.!a34
>
> No [:alnum:] after the \.
>
> Your expression asks for *at least one* [:alnum:]
>
> Changing + to * would make that match.
>
> > Now when I took your example and added the $ at the end, like so:
>
> > print(eregi("^([[:alnum:]]+\.[[:alnum:]]+)$", $string) ? 'matched' :
> > 'no
> > match');
>
> > Everything that MATCHED in example 1 no longer matched,
>
> Right, because it had a [:punct:] before the end of the string and you
> forced it to only pick up [:alnum:]'s
>
> -Brian
> --
> PGP is spoken here: 0xE4D0C7C8
> Please, DO NOT carbon copy me on list replies.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>