To be more constructive -- first off thanks for commenting your code and explaining it to n00bs. Secondly, if you want to use regular expressions, the preg_ functions are supposed to be faster/better. Thirdly, try \'/^34\.12\.233\.254/$\' to match one address or \'/^34\.12\.233\.(1|2)?[0-9]{1,2}/$\' to match a range. ^ means \"Beginning of string\" and $ means \"end\" when they are used in the first and last positions ([^6] means any character except 6)