code: public static boolean matches(String regex, CharSequence input) {
          Pattern p = Pattern.compile(regex);
          return p.matcher(input).matches();
      }
docs: Compiles the given regular expression and attempts to match the given
  input against it.
  <br>
  An invocation of this convenience method of the form
  
  <blockquote><pre>
  Pattern.matches(regex, input);</pre></blockquote>
  
  behaves in exactly the same way as the expression
  
  <blockquote><pre>
  Pattern.compile(regex).matcher(input).matches()</pre></blockquote>
  <br>
  If a pattern is to be used multiple times, compiling it once and reusing
  it will be more efficient than invoking this method each time.
  
  @param  regex
  The expression to be compiled
  
  @param  input
  The character sequence to be matched
  
  @throws  PatternSyntaxException
  If the expression's syntax is invalid