Java Regex

Sort by

recency

|

681 Discussions

|

  • + 1 comment

    class MyRegex { String pattern = "^((25[0-5]|2[0-4]\d|1\d\d|0?\d?\d)\.){3}" + "(25[0-5]|2[0-4]\d|1\d\d|0?\d?\d)$"; }

  • + 1 comment

    class MyRegex {

    String pattern =
        "^(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\." +
        "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\." +
        "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\." +
        "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$";
    

    }

    it was getting the compilation error how to

  • + 0 comments

    The process felt very manageable, and the staff guided me through each step. With Invisalign Newnan, I noticed gradual improvements in my teeth alignment without any discomfort. Scheduling appointments was simple, and following the treatment plan became easy and stress-free. Overall, it made staying consistent with the aligners much more straightforward.

  • + 1 comment
        public static void main(String[] args) {
            
            // Class with pattern
            class MyRegex {
                String pattern = "^((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$";
                }
                
            // Create a class and Scanner instances
            MyRegex myRegex = new MyRegex();
            Scanner sc = new Scanner(System.in);
    				
            // Iterate on input ip addresses
            while (sc.hasNext()) {
                String str = sc.next();
    						
                // Print true if it matches or false if it doesn't
                System.out.println(str.matches(myRegex.pattern));
            }
            // Close the Scanner
            sc.close();
        }
    
  • + 1 comment

    //Write your code here class MyRegex{ public String pattern;

    public MyRegex() {
        this.pattern = "^(\\d{1,2}\\.|[01]\\d{2}\\.|2[0-4]\\d\\.|25[0-5]\\.){3}(\\d{1,2}|[01]\\d{2}|2[0-4]\\d|25[0-5])$";
    }
    

    }