title: Extract the contents of heading tags (h1 to h6) using regex in java
body: <p>I want to extract the contents of all heading tags from a web page.
  I tried this regex </p>
  
  <blockquote>
    <p><code>(?i)&lt;h([1-6].*?)&gt;(.*?)&lt;/h([1-6])&gt;</code></p>
  </blockquote>
  
  <p>The problem is if head tag is like this-</p>
  
  <blockquote>
    <p><code>&lt;h1&gt;&lt;I&gt;Contents&lt;/I&gt;&lt;/h1&gt;</code></p>
  </blockquote>
  
  <p>its giving me output -</p>
  
  <blockquote>
    <p><code>&lt;I&gt;Contents&lt;/I&gt;.</code></p>
  </blockquote>
  
  <p>I want it to print only </p>
  
  <blockquote>
    <p>Contents</p>
  </blockquote>
  
  <p>in output.
  How should I modify this?</p>