code: private static boolean match(String regExp, String userInput) {
          Pattern pattern = Pattern.compile(regExp);
          Matcher matcher = pattern.matcher(userInput);
          if (matcher.find())
              return true;
          else
              return false;
      }
docs: Helper method for regular expression matching.
  @param regExp regular expression String
  @param userInput user's input
  @return the regular expression matched the user input