|
Posted by Michael Fesser on 02/06/07 13:46
..oO(gfrith@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
Navigation:
[Reply to this message]
|