[thelist] regex help

sam foster potatosculptor at gmail.com
Fri Aug 25 09:32:38 CDT 2006


In perl you could use a negative lookahead to allow you to match things like
"12345", or 12345, - where you're just looking for a 5 digit string,
but not necessarily at the end of the string you're matching in

/\d{5}(?=$|\D)/

This is only different to

/\d{5}($|\D)/

.. in that in the latter, $& (lastMatch) includes the trailing
character, whereas the match in the non-capturing parentheses (?=)
don't get included in $&.

Does anyone know if php's regexp implementation supports this too?

Sam


On 8/25/06, Tom Dell'Aringa <pixelmech at gmail.com> wrote:
> Thanks guys! Appreciate the explanation :) Let me just say....doh.
>
> On 8/24/06, Anthony Baratta <anthony at baratta.com
> <http://lists.evolt.org/mailman/listinfo/thelist>> wrote:
> >* Try this...
> *>*
> *>* ^\d{5}$
> *



More information about the thelist mailing list