Answers for "regex java ip address"

1

java ip regex pattern

String pattern = "([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])";
Posted by: Guest on September-23-2020
0

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();
}
Posted by: Guest on November-09-2020
0

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();
	}
Posted by: Guest on October-30-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language