title: Java Regular expression
body: <p>I have a string and a pattern that I want to search for in that string. Now, when I match the pattern in the string, I want to know the string that matches my pattern.</p>
  
  <pre><code>String template = "&lt;P ALIGN=\"LEFT\"&gt;&lt;FONT FACE=\"Verdana\" SIZE=\"12\"&gt; My Name is xyz &lt;/FONT&gt;&lt;/P&gt;";
  
  String pattern = "&lt;FONT.*&gt;";
  
  Pattern.compile(pattern,Pattern.CASE_INSENSITIVE);
  </code></pre>
  
  <p>How can I find out the string that matches the pattern in my template.</p>
  
  <p>i.e I want to get <code>&lt;FONT FACE=\"Verdana\" SIZE=\"12\"&gt;</code> as the result. Is there any method provided by the regex library in Java which can help me?</p>
  
  <h2>Update:</h2>
  
  <p>What is the regular expression that can match <code>&lt;FONT FACE=\"Verdana\" SIZE=\"12\"&gt; My Name is xyz &lt;/FONT&gt;</code> and <code>&lt;LI&gt;&lt;FONT FACE=\"Verdana\" SIZE=\"12\"&gt; My Name is xyz &lt;/FONT&gt;&lt;/LI&gt;</code> and it should not be greedy in a given text.</p>