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 for validating the IP address
String pattern = "^(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$";
}
public class Main {
public static void main(String[] args) {
// Create an instance of MyRegex class
MyRegex myRegex = new MyRegex();
Java Regex
You are viewing a single comment's thread. Return to all comments →
import java.util.regex.*;
class MyRegex { // Regular expression for validating the IP address String pattern = "^(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$"; }
public class Main { public static void main(String[] args) { // Create an instance of MyRegex class MyRegex myRegex = new MyRegex();
}