Revision: 21187
Updated Code
at December 6, 2009 12:15 by rupakdhiman
Updated Code
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ To use this expression follow the code below. //Save the expression in a variable. $correct_ip_format = "/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"; //some input from a user through a text field or from a server. $user_input = $_REQUEST['ip_address']; //match the two input's and save it in a variable. ip_match = preg_match($correct_ip_format, $user_input); //Condition goes here. if(ip_match){ echo "Correct IP Address"; } else{ echo "Incorrect IP Address"; }
Revision: 21186
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 6, 2009 12:10 by rupakdhiman
Initial Code
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ To use this expression follow the code below. //Save the expression in a variable. $correct_ip_format = "/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"; //some input from a user through a text field or from a server. $user_input = $_REQUEST['ip_address']; //match the two input's and save it in a variable. ip_match = preg_match($correct_ip, $user_input); //Condition goes here. if(ip_match){ echo "Correct IP Address"; } else{ echo "Incorrect IP Address"; }
Initial URL
Initial Description
This is a code to match an IP Address from a source.
Initial Title
Regular expression to match an IP Address
Initial Tags
ip
Initial Language
PHP