The Java String API provides some useful methods to evaluate regular expressions against a text represented by the String object. Let's list those methods from the String class:
Method Signature |
Purpose |
boolean matches(String regex) |
Matches the given regular expression against the string that the method is invoked on and returns true/false, indicating whether the match is successful (true) or not (false). |
String replaceAll(String regex, String replacement) |
Replaces each substring of the subject string that matches the given regular expression with the replacement string and returns the new string with the replaced content. |
String replaceFirst(String regex, String replacement) |
This method does the same as the previous one with the exception that it replaces only the first substring... |