You are here: Re: Combining 2 preg matches. « PHP Programming Language « IT news, forums, messages
Re: Combining 2 preg matches.

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация