Match grouped multi-line float values between brackets
In the below example data, I want to extract all the float values between brackets belonging only to "group1" using regex, but not the values from other groups ("group2", "group3" etc.). A requirement is that it is done via regex in python. Is this possible with regex at all?
Regex patterns attempts:
I tried the following patterns, but they capture either everything or nothing:
- Matches every float value in all groups:
([+-]*\d+\.\d+),- Matches no value in any groups:
group1 = \[ ([+-]*\d+\.\d+), \]
What should I do to make this work? Any suggestions would be very welcome!
Example data:
group1 = [
1.0,
-2.0,
3.5,
-0.3,
1.7,
4.2,
]
group2 = [
2.0,
1.5,
1.8,
-1.8,
0.7,
-0.3,
]
group1 = [
0.0,
-0.5,
1.3,
0.8,
-0.4,
0.1,
]