I have a string from which I want to extract value for test1.
The string is :
I_ID [I_ITEM = [I_ITEM [test1 = F135], I_ITEM [test1 = W1972544]]]]]
Any pointers will be helpfull
>Solution :
Assuming you want to capture all values whose keys are test1, we can try using re.findall:
inp = "I_ID [I_ITEM = [I_ITEM [test1 = F135], I_ITEM [test1 = W1972544]]]]]"
values = re.findall(r'\btest1\s*=\s*(.*?)\]', inp)
print(values) # ['F135', 'W1972544']