java ip regex pattern
String pattern = "([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])";
java ip regex pattern
String pattern = "([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])";
java regex ip
public static boolean isIP(String ip) {
Pattern p = Pattern.compile("(([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.){3}([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])");
Matcher m = p.matcher(ip);
return m.matches();
}
regex java ip address
System.out.println("IPv4: " + ipv4Adresse("192.168.100.1"));
System.out.println("IPv6: " + ipv6Adressen("2001:0db8:85a3:08d3:1319:8a2e:0370:7344"));
System.out.println("MAC-Adresse: " + macAdressen("88:66:5a:44:a9:12"));
public static boolean ipv4Adresse(String ipAdresse) {
Pattern pattern = Pattern.compile("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(ipAdresse);
return matcher.find();
}
public static boolean ipv6Adressen(String ipAdresse) {
Pattern pattern = Pattern.compile("^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(ipAdresse);
return matcher.find();
}
public static boolean macAdressen(String macAddress) {
Pattern pattern = Pattern.compile("((?:[a-zA-Z0-9]{2}[:-]){5}[a-zA-Z0-9]{2})", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(macAddress);
return matcher.find();
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us