title: How to remove texts between &lt;ref&gt; and &lt;/ref&gt;
body: <p>I am having some text within html tags in a document. The text looks something like this</p>
  
  <pre><code>I need this text &amp;lt;ref&amp;gt; Some unwanted text &amp;lt;/ref&amp;gt; I need this text too
  </code></pre>
  
  <p>and</p>
  
  <pre><code>I need this text &amp;lt;ref Some random text /&amp;gt; I need this text too
  </code></pre>
  
  <p>How so I remove the unwanted text along with the enclosing tags?</p>
  
  <hr>
  
  <p>I tried using this regular expression. But it is not working.</p>
  
  <pre><code>&amp;lt;ref(.*?)&amp;gt;(.*?)&amp;lt;/ref&amp;gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&amp;lt;ref(.*?)&amp;gt;
  </code></pre>
  
  <p>Trying this way in Java is not helping:</p>
  
  <pre><code>regex = "&amp;lt;ref(.*?)&amp;gt;(.*?)&amp;lt;/ref&amp;gt;";
  p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE); 
  m = p.matcher(s);
  while(m.find()){
     m.replaceAll(" ");           
  }
  </code></pre>
  
  <p>Any idea how do I get the solution?</p>