Page 1 of 1

pattern help...

Posted: Mon Feb 20, 2006 10:16 am
by welsh_sponger
Hello.

Im trying to match a pattern and extract some values... im having some problems...

This is what i have at the moment...

Code: Select all

$page = file_get_contents("http://www....");

preg_match( "/[\w\s]+[\w\s]+[\w\s]+[\w\s]+[\w\s](\d{3}\s+)(\d+\.\d\s+)[\d+\.\s+)]+(\d\.\d\s+)(\d)/i", $page, $matches);
Im trying to match from this string...

41001 2006 02 20 11 220 3.0 6.0 1.6 9

My code is producing the result, 220 3.0 1.6 9, which is correct! however the values are constanly changning, and sometimes the 6.0 value above becomes 'MM' which obviously messes up the pattern. What do i need to do to the pattern to allow for both possiblities...?

I also need to verify that the string starts with the first value of 41001 exactly, how can this be done?

Thanks very much...

Posted: Mon Feb 20, 2006 10:26 am
by feyd

Code: Select all

#^\s*41001\s+(?:\d+\s+){4}(\d+(?:\.\d*)?)\s+(\d+(?:\.\d*)?)\s+(?:\d+(?:\.\d*)?|[a-z]+)\s+(\d+(?:\.\d*)?)\s*$#im
:?: