title: How can I remove all font tags that have nothing but whitespace in them, using Perl?
body: <p>I'm trying to do a match in Perl, using the following regex:</p>
  
  <pre><code>s/&lt;font(.*?)&gt;[\t\f ]*&lt;\/font&gt;//gi;
  </code></pre>
  
  <p>What I want it to do is to remove all font tags that don't have anything inside.</p>
  
  <p>Unfortunately, it doesn't stop after <code>&lt;font</code> at the first <code>&gt;</code> it will go until the <code>&gt;</code> from before <code>&lt;/font&gt;</code>.</p>
  
  <p>Any pointers on what is wrong with the regex?</p>
  
  <pre><code>my $text1 = '&lt;font color="#008080"&gt;&lt;span style="background: #ffffff"&gt;&lt;/span&gt;&lt;/font&gt;';
  my $text2 = '&lt;font color="#008080"&gt;    s&lt;/font&gt;';
  my $text2 = '&lt;font&gt;&lt;/font&gt;';
  $text1 =~ s/&lt;font(.*?)&gt;[\t\f ]*&lt;\/font&gt;//gi;
  $text2 =~ s/&lt;font(.*?)&gt;[\t\f ]*&lt;\/font&gt;//gi;
  $text3 =~ s/&lt;font(.*?)&gt;[\t\f ]*&lt;\/font&gt;//gi;
  print "$text1\n$text2\n$text3\n";
  </code></pre>
  
  <p>will print </p>
  
  <pre><code> 
  &lt;font&gt;s&lt;/font&gt;
   
  </code></pre>