I've been trying to split the string i find with regex into list elements, since re.findall returns a list. This is my source string:
vars.duh["1"] = {
oid_1 = "1"
oid_2 = "2"
oid_3 = "3"
}
This is what i got so far:
regex = re.compile(r"(?<=vars\.duh\[\"1\"\] = {)[^}]*(?=})")
return re.findall(regex, string)
This is the output:
['\n oid_1 = "1"\n oid_2 = "2"\n oid_3 = "3"\n']
It seems like 1 single list element gets returned, which is obvious, since the regex matches this one string. Is it possible to split by \n in the regex, before the list is created, so the list returns multiple elements like so:
[' oid_1 = "1"',' oid_2 = "2"',' oid_3 = "3"']
The number of different oids is dynamic, so i'm afraid i can't work with capture groups, can i? Is there a python or regex way to handle this? cheers
re, just split the result with a newline.