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/17/06 15:24

Rik wrote:
> frizzle wrote:
> >>> $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.
> >> Good point. It doesn't make sense to use assertions when you'll
> >> capture
> >> the matches anyway.
> > Somehow, i believe Rik's solution, gave me problems ...
> >
> > '/^(?:[a-z0-9]|[a-z0-9][_\-][a-z0-9])+$/'; gave problems.
> > '/^(?:[a-z0-9]|(?<=[a-z0-9])[-_](?=[a-z0-9]))+$/' didn't.
> >
> > An example string that gave problems is:
> > really_a_made_up_string
>
>
> Ah, forgot that in [a-z0-9][_\-][a-z0-9] the character on the right is
> already matched, so it won't work as a start for the second _ in _a_....
>
> This one should still be working though:
> $regex ='/^(?:[a-z0-9]+(?:[_\-][a-z0-9]+)*)$/';
>
> Grtz,
> --
> Rik Wasmus

ok, dankjewel / thanks a lot.

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

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