title: how to eliminate an specific part of html file in python
body: <p>I am working on a html file which has item 1, item 2, and item 3. I want to delete all the text that comes after the LAST item 2. There may be more than one item 2 in the file. I am using this but it does not work:</p>
  
  <pre><code>text = """&lt;A href="#106"&gt;Item&amp;nbsp;2. &lt;B&gt;Item&amp;nbsp;2. Properties&lt;/B&gt; this is an example this is an example"""
  
  &gt;&gt;&gt; a=re.search ('(?&lt;=&lt;B&gt;)Item&amp;nbsp;2.',text)
  &gt;&gt;&gt; b= a.group(0)
  &gt;&gt;&gt; newText= text.partition(b)[0]
  &gt;&gt;&gt; newText
  '&lt;A href="#106"&gt;'
  </code></pre>
  
  <p>it deletes the text after the first item 2 not the second one.</p>