The java.util.regex Package for Pattern Matching in Java


Regular expressions are a powerful tool for validating, parsing, and manipulating strings, with Pattern and Matcher classes providing the core functionality.

Source Code

Pattern pattern = Pattern.compile("^(.+)@(.+)$");
Matcher matcher = pattern.matcher("[email protected]");
if (matcher.matches()) {
    System.out.println("Email is valid");
} else {
    System.out.println("Email is not valid");
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments