title: How do I remove a string from a BeautifulSoup instance given a certain criteria?
body: <pre><code>for tables in apple_tables:
      text = tables.getText()
      a = len(re.findall(r"\d", text))
      b = len(text)
      print(a/b)
      print(text)
      if a/b &gt;= .1:
          apple_soup_16.remove? replace?  #I need all text in this instance completely gone
  </code></pre>
  
  <p>Here is what I have so far.  Essentially, what I need to happen is, if over 10% of characters in each table (of which I have a list) are numbers, I need to remove the entire table from this instance of the loop from the BeautifulSoup instance.<br>
  Is this possible to do while it's already in BeautifulSoup?  If not, how would I go about doing it before putting it into BS?  </p>
  
  <p>Thanks, and I hope it's clear what I'm trying to do here.  I think I'm just mostly having issues with the BeautifulSoup library, I haven't used it much. </p>
  
  <p>EDIT:  Here are the first two examples of what each table looks like in apple_tables:</p>
  
  <pre><code>(&lt;table cellpadding="0" cellspacing="0" style="FONT-FAMILY:TIMES NEW ROMAN;FONT-SIZE:10PT;MARGIN-LEFT:AUTO;MARGIN-RIGHT:AUTO;WIDTH:100%;BORDER-COLLAPSE:COLLAPSE;TEXT-ALIGN:LEFT;"&gt;&lt;tr&gt;&lt;td colspan="1"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="WIDTH:100%;"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="VERTICAL-ALIGN:BOTTOM;PADDING-LEFT:2PX;PADDING-TOP:2PX;PADDING-BOTTOM:2PX;PADDING-RIGHT:2PX;BORDER-TOP:1PX SOLID #000000;BORDER-BOTTOM:1PX SOLID #000000;"&gt;&lt;div style="OVERFLOW:HIDDEN;HEIGHT:5PX;FONT-SIZE:10PT;"&gt;&lt;font style="FONT-FAMILY:INHERIT;FONT-SIZE:10PT;"&gt; &lt;/font&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;,
   &lt;table cellpadding="0" cellspacing="0" style="FONT-FAMILY:TIMES NEW ROMAN;FONT-SIZE:10PT;MARGIN-LEFT:AUTO;MARGIN-RIGHT:AUTO;WIDTH:19.53125%;BORDER-COLLAPSE:COLLAPSE;TEXT-ALIGN:LEFT;"&gt;&lt;tr&gt;&lt;td colspan="1"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="WIDTH:100%;"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="VERTICAL-ALIGN:BOTTOM;PADDING-LEFT:2PX;PADDING-TOP:2PX;PADDING-BOTTOM:2PX;PADDING-RIGHT:2PX;BORDER-BOTTOM:1PX SOLID #000000;"&gt;&lt;div style="OVERFLOW:HIDDEN;HEIGHT:5PX;FONT-SIZE:10PT;"&gt;&lt;font style="FONT-FAMILY:INHERIT;FONT-SIZE:10PT;"&gt; &lt;/font&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;)
  </code></pre>
  
  <p>apple_soup_16 is a currently full BS instance of the entire html for multiple companies.  I need anywhere in which the instance of a table has greater than 10% number to be removed from that BeautifulSoup object.  Putting the BeautifulSoup code in here shouldn't really be necessary, as these tables are coming directly from the BS object.  Every table is in the Soup, but I only need the 10% ones to be removed. </p>