I have an IP address for which I want to define a regular expression to write it in its proper format. Please suggest a way in which I can achieve this.
-
1public static boolean isValidIP(String ipAddr){ Pattern ptn = Pattern.compile("^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$"); Matcher mtch = ptn.matcher(ipAddr); return mtch.find(); } This will workAkhil– Akhil2016-02-09 09:16:56 +00:00Commented Feb 9, 2016 at 9:16
Add a comment
|