I’m working on writing a parser to extract information from the output given below
Actually i need to get all the three texts which are inbetween ‘–‘. so i wrote a regular expression as below
import re
def parse_ib_write_bw(mystr):
output = dict()
# match = re.search('--+n(n|.)*?--+', mystr, re.I)
match = re.search('--+n(.*)--+(.*)--+(.*)--+', mystr, re.DOTALL)
if match:
print(match.groups(1))
print(match.groups(2))
print(match.groups(3))
parse_ib_write_bw(my_str)
My understanding is:
--+n(.*)--+ --> This would give the output of the first block until second '---' is found
(.*)--+ --> would give the second block until the third '--' is found
(.*)--+ --> would give the third block until the final'--' is found
but actually i get the entire output. kindly help me to understand where i;m going wrong with my understanding.