Matches/Contains of String class
Oct 5, 2023
Comparing the input string using the Matches function and the contains function of the String class.
Matches:
public boolean matches(String regex)
- Tells whether or not this string matches the given regular expression.
- An invocation of this method of the form str.matches(regex) yields exactly the same result as the expression.
Pattern
.matches
(regex, str)- This function allows for comparing strings with a exact match.
Contains:
public boolean contains(CharSequence s)
- Returns true if and only if this string contains the specified sequence of char values.
- This implies that if my charSequence is present at the beginning, middle, or end of the input string (or anywhere within it), it will result in a true value.