code: public String match(CharSequence text)
      {
          try
          {
              if (text.length() == 0)
              {
                  if (acceptEmpty)
                  {
                      return "";
                  }
                  else
                  {
                      throw new SyntaxErrorException("empty string not accepted");
                  }
              }
              InputReader reader = Input.getInstance(text);
              int rc = match(reader);
              if (rc == 1 && reader.read() == -1)
              {
                  return reader.getString();
              }
              else
              {
                  throw new SyntaxErrorException("syntax error"
                          + "\n"
                          + reader.getLineNumber() + ": " + reader.getLine()
                          + "\n"
                          + pointer(reader.getColumnNumber() + 2));
              }
          }
          catch (IOException ex)
          {
              throw new IllegalArgumentException("can't happen");
          }
      }
docs: Attempts to match input to regex
  @param text
  @return
  @throws SyntaxErrorException