title: Java Regex group 0
body: <p>Can someone please help me to explain the following code? Thanks. I am a little bit confused about the regex grouping.</p>
  
  <pre><code>public static String evaluate(String s) {
      if (s == null) return "";
  
      Matcher m = Pattern.compile("[0-9]*").matcher(s);
  
      if (m.find()) {
          MatchResult mr = m.toMatchResult();
          return mr.group(0);
      }
      return "";
  }
  </code></pre>