public static IP parseFromString(String ip){
  String regex="\\s*(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\s*";
  Pattern pattern=Pattern.compile(regex);
  Matcher m=pattern.matcher(ip);
  checkArgument(m.find(),"IP string should match the regex:%s",regex);
  int a=Integer.parseInt(m.group(1));
  int b=Integer.parseInt(m.group(2));
  int c=Integer.parseInt(m.group(3));
  int d=Integer.parseInt(m.group(4));
  return new IP(a,b,c,d);
}

public static IP parseFromString ( String ip ) { String regex = "\\s*(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\s*" ; Pattern pattern = Pattern . compile ( regex ) ; Matcher m = pattern . matcher ( ip ) ; checkArgument ( m . find ( ) , "IP string should match the regex:%s" , regex ) ; int a = Integer . parseInt ( m . group ( 1 ) ) ; int b = Integer . parseInt ( m . group ( 2 ) ) ; int c = Integer . parseInt ( m . group ( 3 ) ) ; int d = Integer . parseInt ( m . group ( 4 ) ) ; return new IP ( a , b , c , d ) ; }
creates a ip instance by a string .
