Reply to Re: Regular expression - match string containing a but not a and b

Your name:

Reply:


Posted by gfrith on 02/09/07 08:19

On Feb 6, 1:46 pm, Michael Fesser <neti...@gmx.de> wrote:
> .oO(gfr...@gmail.com)
>
>
>
> >I want to match on all strings which end _id, but not those ending
> >row_id.
>
> >Some sample strings:
>
> >row_id
> >parent_id
> >person_id
> >person
>
> >I'd like to match all but the 1st and last.
>
> >I've tried many variants, including
>
> >preg_match('/(row)\w{0}_id$/',$subject);
> >preg_match('/(row){0}_id$/',$subject);
> >preg_match('/(?!row)_id$/',$subject);
>
> The last one was very close:
>
> preg_match('/(?<!row)_id$/', $subject);
>
> Notice the '<' to make it a negative look-behind assertion instead of
> negative look-ahead.
>
> Micha

That did the trick, thanks Micha!

[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

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