Matches
matches()
A String
object has a matches()
method:
public boolean matches(String RE)
returns true if the regular expression RE
matches the string, returns false otherwise.
throws a PatternSyntaxException
if the syntax
of RE is invalid.
For now, ignore the exceptions that might be thrown. (They are unchecked exceptions, so you don't need to do anything special in your code.) (Of course, your program will halt when one is thrown.)
Are both the string that owns the method and the regular expression String
objects?