Python usage of regular expressions
Question: How can I extract _string1#string2_ from the bellow line?

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

The # character and the structure of the line is always the same.


Answer: I would like to refer you to this
[gem](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-
xhtml-self-contained-tags):

In synthesis a regex is not the appropriate tool for this job  
Also have you tried an
[XML](https://docs.python.org/3/library/xml.etree.elementtree.html) parser
instead?

EDIT:

    
    
    import xml.etree.ElementTree as ET
    a = "<html><body><p style=\"margin:0;\">string1#string2</p></body></html>"
    root = ET.fromstring(a)
    c = root[0][0].text
    
    OUT:
    c
    'string1#string2'
    
    d = c.replace('#', ' ').split()
    Out: 
    d 
    ['string1', 'string2']
    

