how to validate the ip address in javarefer ual:ottturi.com/**
* @author lautturi.com
* Java example: validate the ip address in java using regular expression.
*/
import java.util.*;
import java.util.regex.*;
public class Lautturi {
public static void main(String[] args) {
String IP = "192.168.1.100";
String pattern =
"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
System.out.println(IP.matches(pattern));
}
}