Snippet : Using Regular Expressions in Java

This snippet helps you to use Regular Expression(Regex) in Java.

String rgx = "String To check";
        if(rgx.matches("Your Regex Here"))
        {
            System.out.println("correct");
        }else{
            System.out.println("wrong");
        }
  • Replace String To check with the text/number you want to check
  • Replace Your Regex Here with a Regular Expression(For example : [0-9])

Post a Comment

Note: Only a member of this blog may post a comment.