I have a string:
mystr = "&marker1\nThe String that I want /\n&marker1\nAnother string that I want /\n"
What I want is a list of substrings between the markers start="&maker1"
and end="/\n"
. Thus, the expected result is:
whatIwant = ["The String that I want", "Another string that I want"]
I've read the answers here:
And tried this but not successfully,
>>> import re
>>> mystr = "&marker1\nThe String that I want /\n&marker1\nAnother string that I want /\n"
>>> whatIwant = re.search("&marker1(.*)/\n", mystr)
>>> whatIwant.group(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'
What could I do to resolve this? Also, I have a very long string
>>> len(myactualstring)
7792818