I need a Python regex to give me all the strings between ~
and ^
from a string like this:
~~~~ AAA ^ BBB ^ CCC > DDD ^
I've tried this:
import re
target = ' ~~~~ AAA > ^ BBB ^ CCC > DDD ^ '
matchObj = re.findall(r'~(.*?)\^', target)
print matchObj
But the result is:
['~~~ ABC ']
What I expect is:
['AAA', 'BBB', 'CCC', 'DDD']
or
['^AAA', '^BBB', '^CCC', 'DDD']
I want to do this because I am trying to extract text from an HTML page like this:
<td class="cell-1"><div><span class="value-frame"> ~~~~ ABC ^ DEF ^ HGK > LMN ^</span></div>
</td>