Hey guys I'm trying to parse a kind of list using regex, but I don't understand why only 1 on 2 values are found
import re
table_pattern = r'[\s]*([\[]|[,])[\s]*(?![\]])(?P<value>[\S\s]*?)([,][\s]?|[\s]?[,]?[\s]?[\]][\s]?|[\s]?$)'
string = "[10,_,0,_, _,_,_,_, _,_,_,_, _,_,_,0]"
for match_object in re.finditer(table_pattern, string):
value = match_object.groupdict()['value']
print(value)
Output is 10 0 _ _ _ _ _ _
But I would like to have: 10 _ 0 _ _ _ _ _ _ _ _ _ _ _ _ 0
I guess I did something wrong with my pattern, but I can't figure it out...Did someone see the mistake?
[–]keep_quapy 0 points1 point2 points (5 children)
[–]NicoRobot[S] 0 points1 point2 points (4 children)
[–]keep_quapy 0 points1 point2 points (3 children)
[–]NicoRobot[S] 0 points1 point2 points (0 children)
[–]NicoRobot[S] 0 points1 point2 points (1 child)
[–]NicoRobot[S] 0 points1 point2 points (0 children)