fork download
  1. import re
  2.  
  3. pattern = r"'[^']+':\s+'(\[)?([0-9]+(?:,\s*[0-9]+)*)(?(1)\])'"
  4. s = "{'Port': '2', 'Array': '[0, 0]', 'Field': '[2,2]', 'foo': '[0, 0]' , 'bar': '[9, 9]'}"
  5. matches = re.finditer(pattern, s)
  6.  
  7. for matchNum, match in enumerate(matches, start=1):
  8. print(match.group(2))
Success #stdin #stdout 0.03s 9608KB
stdin
Standard input is empty
stdout
2
0, 0
2,2
0, 0
9, 9