I am trying to parse the content of a wiki page.
In a string like this:
==Heading1==
<test>
some text here
</test>
==Heading2==
<test>
even more text
</test>
I need to obtain "Heading1", "some text here", "Heading2" and "even more text".
I got this to work:
import re
MyStr = "<test>some text here</test>
m=re.compile('<test>(.*?)</test>').search(MyStr)
print m.group(1)
it produces "some text here".
But I tried this:
MyStr = "==some text here=="
m=re.compile('<test>(.*?)</test>').search(MyStr)
print m.group(1)
and it had an error.
I also tried this:
MyStr = "<test>some text here</test> <other> more text </other> <test> even more text</test>"
m=re.compile('<test>(.*?)</test>').search(MyStr)
print m.group(1)
print m.group(2)
and it had an error getting group(2) (which I was hoping was the second occurrence of the matching string?)
Can anyone point me in the right direction?
Thanks,
Dave