By now, we’ve had quite a bit of practice with regular expressions. matches is a method which compares a string with a regular expression; it matches a regular expression pattern with an entire string.
matches is called on the string that you want to compare a regular expression with. It’s a boolean type and returns true if the string matches and false if it doesn’t. The syntax is as follows.