title: Pattern/Matcher group() to obtain substring in Java?
body: <p><strong>UPDATE:</strong> Thanks for all the great responses! I tried many different regex patterns but didn't understand why m.matches() was not doing what I think it should be doing. When I switched to <strong>m.find()</strong> instead, as well as adjusting the regex pattern, I was able to get somewhere. </p>
  
  <hr>
  
  <p>I'd like to match a pattern in a Java string and then extract the portion matched using a regex (like Perl's $&amp; operator). </p>
  
  <p>This is my source string "s": <code>DTSTART;TZID=America/Mexico_City:20121125T153000</code>
  I want to extract the portion "America/Mexico_City". </p>
  
  <p>I thought I could use Pattern and Matcher and then extract using m.group() but it's not working as I expected. I've tried monkeying with different regex strings and the only thing that seems to hit on m.matches() is <code>".*TZID.*"</code> which is pointless as  it just returns the whole string. Could someone enlighten me?</p>
  
  <pre><code> Pattern p = Pattern.compile ("TZID*:"); // &lt;- change to "TZID=([^:]*):"
   Matcher m = p.matcher (s);
   if (m.matches ()) // &lt;- change to m.find()
      Log.d (TAG, "looking at " + m.group ()); // &lt;- change to m.group(1)
  </code></pre>