input = "{1} {John Travis} {was} {here}"
Let's suppose that I want to get strings that are inside of the second and the third pair of brackets. So the expected output is:
output = "John Travis was"
I tried to use array split with spaces as a separator, expecting as result something like:
array = ["{1}", "{John Travis}", "{was}", "{here}"]
array[1] = re.sub("{", "", array[1])
array[1] = re.sub("}", "", array[1])
array[2] = re.sub("{", "", array[2])
array[2] = re.sub("}", "", array[2])
#expected result: array[1] + array[2] ( "John Travis was" )
But I remembered that I have the separator " " on 'John Travis', resulting:
array = ["{1}", "{John", "Travis}", "{was}", "{here}"]
array[1] = re.sub("{", "", array[1])
array[2] = re.sub("}", "", array[2])
array = ["{1}", "John", "Travis", "{was}", "{here}"]
#unexpected result: array[1] + array[2] ( "John Travis" )
How to proceed?
Thanks for listening.