Reply to Re: Combining 2 preg matches.

Your name:

Reply:


Posted by Rik on 07/16/06 14:46

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

[Back to original 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

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