How to match a fixed number of digits with regex in PHP?

Posted by user198729 on Stack Overflow See other posts from Stack Overflow or by user198729
Published on 2010-03-25T08:23:15Z Indexed on 2010/03/25 8:33 UTC
Read the original article Hit count: 330

Filed under:
|

I want to retrieve the consecutive 8 digits out of a string.

"hello world,12345678anything else"

should return 12345678 as result(the space in between is optional).

But this should not return anything:

"hello world,123456789anything else"

Because it has 9 digits,I only need 8 digits unit.

© Stack Overflow or respective owner

Related posts about php

Related posts about regex