|
Posted by frizzle on 07/16/06 15:25
Rik wrote:
> Rik wrote:
> > $regex ='/ #opening delimiter
> > ^ #start of string
> > (?: #start of non-capturing group
> > [a-z] #any character between a and z
> > | #OR
> > (?<= #start of positive lookbehind (is preceeded
> > by..) [a-z] #any character between a and z
> > ) #end of positive lookbehind
> > [-_] #character - or _ (not incorrect, but probably
> > better to [_\-],[_-] or [\-_]
> > (?= #start of positive lookahead
> > [a-z] #any character between a and z
> > ) #end of positive lookahead
> > ) #end of non-capturing group
> > + #1 or more times, greedy
> > $ #end of string
> > /x';
> >
>
>
> It just occured to me that, allthough a wonderfull example:
>
> $regex ='/^(?:[a-z]|[a-z][_\-][a-z])+$/';
>
> ...will do just fine.
>
> equally so:
> $regex ='/^(?:[a-z]+(?:[_\-][a-z]+))+$/';
>
> Lookahead & -behind are unneccessary in this case, and this keep it simple.
>
> Grtz,
> --
> Rik Wasmus
Wow, thanks for the explanation!
Nice link there as well. Going right into my bookmarks.
Frizzle.
[Back to original message]
|