Regular Expression removing <![CDATA[
<p>I have this regular expression: </p>

<pre><code>&lt;/title&gt;[\s]*&lt;description[^&gt;]*&gt;(.*?)&lt;img
</code></pre>

<p>which takes the string: </p>

<pre><code>&lt;title&gt;Insane price of last Ford Falcon V8s&lt;/title&gt;
        &lt;description&gt;&lt;![CDATA[FORD dealers are charging a staggering $30,000 more than the recommended retail price â up from $60,000 to $90,000 â for the final Falcon V8 sedans as buyers try to secure a future classic.&lt;img alt="" border="0" src="https://pixel.wp.com/b.gif?host=www.couriermail.com.au&amp;#038;blog=87782261&amp;#038;post=1205849&amp;#038;subd=couriermailatnewscorpau&amp;#038;ref=&amp;#038;feed=1" width="1" height="1" /&gt;]]&gt;&lt;/description&gt;
</code></pre>

<p>how can i edit this regular expression to also remove <code>&lt;![CDATA[</code></p>

<p>Regular expressions are really mighty tool. This includes a high risk of getting bugs into your code, especially when you do not know how to handle them exactly (it seems this is the case here).</p>

<p>You should always go with Python's built-in string class first and <em>only</em> use RegEx, if it is necessary.</p>

<p>If you have your string <code>my_str</code>, then the following code replaces a substring in <code>my_str</code>:</p>

<pre><code>my_str = "hello world"
my_str.replace("lo", "")
&gt;&gt;&gt; "hel world"
</code></pre>

<p><code>str.replace</code> searches for a "lo" in this case and replaces it with "" (nothing, thus deleting it). Of course you can alter this values as you like.</p>

<p>Take a look at <a href="https://docs.python.org/2/library/string.html" rel="nofollow">Python's documention for Strings</a>.</p>

python html regex cdata