Page 1 of 1

IP address

Posted: Thu Aug 18, 2011 5:59 am
by spacebiscuit
Hi,

I am trying to match the first half of an IP address using:

preg_match_all('![0-9]*.[0-9]*.!',"$ip", $matches);

This however seems to find a match for each level of the address and the period. If I input '255.255.255.0' I want the match to be: '255.255'.

I don't think I am far away, is it possible?

Thanks,

Re: IP address

Posted: Thu Aug 18, 2011 3:33 pm
by pickle
/[0-9]{1,3}\.[0-9]{1,3}/