Paul Brennan Paul Brennan - 8 months ago 44
PHP Question

PHP - Searching strings from a certain format

I've seen other examples using regex however I'm a little bit troubled trying to format mine correctly, I'll have a list of numbers like this:

However I only want to have the actual 4 numbers but the numbers could turn into multiple digits per line for example (up to 3) how would I go about using PHP to do this? I presume I would have to put them all into a array first then for each in array, then I am confused on how to remove the extra letters.

Thanks in advance!

Answer Source

Yours Code is:

$input = <<<TEST
if (!preg_match_all("#(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})+#", $input, $matches))
    print("NOT FOUND!");