code: public static String find(CharSequence self, Pattern pattern) {
          Matcher matcher = pattern.matcher(self.toString());
          if (matcher.find()) {
              return matcher.group(0);
          }
          return null;
      }
docs: Finds the first occurrence of a compiled regular expression Pattern within a String.
  If the pattern doesn't match, null will be returned.
  <p>
  For example, if the pattern doesn't match the result is null:
  <pre>
  assert null == "New York, NY".find(~/\d{5}/)
  </pre>
  
  If it does match, we get the matching string back:
  <pre>
  assert "10292" == "New York, NY 10292-0098".find(~/\d{5}/)
  </pre>
  
  If we have capture groups in our expression, the groups are ignored and
  we get back the full match:
  <pre>
  assert "10292-0098" == "New York, NY 10292-0098".find(~/(\d{5})-?(\d{4})/)
  </pre>
  If you need to work with capture groups, then use the closure version
  of this method or use Groovy's matcher operators or use <tt>eachMatch</tt>.
  
  @param self    a CharSequence
  @param pattern the compiled regex Pattern
  @return a String containing the matched portion, or null if the regex pattern doesn't match
  @see #find(String, java.util.regex.Pattern)
  @since 1.8.2