Monday 3 September 2018

PHP regex: Find all 6-digit numbers in a string that does not end in 00

I'm trying to find all the 6 digit numbers in a string that do not end in 00. Something like that /([0-9]{4})([^00])/ //i know this is wrong

so the string
asdfs dfg_123456_adsagu432100jhasj654321
will give me
results=[123456,654321] and not 432100
Thanks
Have a good day

Use negative lookbehind: \d{6}(?<!00)

See also

0 comments:

Post a Comment