regex for an ip
Posted: Sat Dec 10, 2005 10:04 am
Can anybody provide me with a regex that checks IP validity (I thought "[0-9]{1,3}/.[0-9]{1,3}/.[0-9]{1,3}/.[0-9]{1,3}) would work but it doesn't. I'm new at regex
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
preg_match("/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(:[0-9]{1,5})?$/", $ipaddr);Jenk wrote:This should be in the RegEx forum, as it is about... RegEx.Code: Select all
preg_match("/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(:[0-9]{1,5})?$/", $ipaddr);
Code: Select all
/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/