java identify IP address regular expression code example Example: java ip regex pattern String pattern = "([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])";