 <p><a href="http://docs.python.org/2/library/re.html#re.sub" rel="nofollow">re.sub</a> does not perform the substitution in-place. It returns a new string with the result of the substitution. You are free to reassign to the original variable name if you like, of course.</p> <p>So what you want is</p> <pre><code>page = re.sub("&amp;amp;", '', page) </code></pre>