fork download
  1. import re
  2.  
  3. pattern = r"[^=\s,]+=(?:'(?:\\+\.\\+)?([^\s,=']+)'|([^\s,=]+))"
  4.  
  5. s = "x=0, y=0, width=1920, height=1080, width_mm=531, height_mm=299, name='\\\\\\\\\\\\\\\\.\\\\\\\\DISPLAY4', is_primary=True"
  6.  
  7. res = [m.group(1) if m.group(1) else m.group(2) for _, m in enumerate(re.finditer(pattern, s), start=1)]
  8. print(res)# your code goes here
Success #stdin #stdout 0.04s 9548KB
stdin
Standard input is empty
stdout
['0', '0', '1920', '1080', '531', '299', 'DISPLAY4', 'True']