How can I check if a string matches a IPv4, IPv6 adress or a domain name like www.google.com? I found this for IPv4: Validating IPv4 string in Java And the same kind of system works for IPv6 but how can I check domain names? EDIT: To clarify: I want to check if a string is a valid server address. Valid