We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
class MyRegex {
// Regular expression pattern to validate an IP address
public static final String pattern =
"(0{0,2}[0-9]|0{0,1}[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\." +
"(0{0,2}[0-9]|0{0,1}[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\." +
"(0{0,2}[0-9]|0{0,1}[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\." +
"(0{0,2}[0-9]|0{0,1}[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])";
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Regex
You are viewing a single comment's thread. Return to all comments →
class MyRegex { // Regular expression pattern to validate an IP address public static final String pattern = "(0{0,2}[0-9]|0{0,1}[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\." + "(0{0,2}[0-9]|0{0,1}[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\." + "(0{0,2}[0-9]|0{0,1}[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\." + "(0{0,2}[0-9]|0{0,1}[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])"; }