Validate IP Address

Usage of regular expression in Java to validate an IP address
Code:


private boolean
validateAnIpAddressWithRegularExpression(String iPaddress){
final Pattern IP_PATTERN =
Pattern.compile("b(?:(?: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]?)b");
return IP_PATTERN.matcher(iPaddress).matches();
}

Advertisements