Python usage of regular expressions
<p>How can I extract <em>string1#string2</em> from the bellow line?</p>

<pre><code>&lt;![CDATA[&lt;html&gt;&lt;body&gt;&lt;p style="margin:0;"&gt;string1#string2&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;]]&gt;
</code></pre>

<p>The # character and the structure of the line is always the same.</p>

<p>I would like to refer you to this <a href="http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags">gem</a>:</p>

<p>In synthesis a regex is not the appropriate tool for this job<br>
Also have you tried an <a href="https://docs.python.org/3/library/xml.etree.elementtree.html" rel="nofollow">XML</a> parser instead? </p>

<p>EDIT: </p>

<pre><code>import xml.etree.ElementTree as ET
a = "&lt;html&gt;&lt;body&gt;&lt;p style=\"margin:0;\"&gt;string1#string2&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;"
root = ET.fromstring(a)
c = root[0][0].text

OUT:
c
'string1#string2'

d = c.replace('#', ' ').split()
Out: 
d 
['string1', 'string2']
</code></pre>

python regex