in reply to Checking for a valid IP number
This is really reinventing the wheel considering there are tons of ready-made solutions for this everyday task. If you do need a variation not covered by these, I'd suggest adding /o to the regexp to have it compile the whole length thing only once.