fork download
  1. import re
  2.  
  3. my_list = ['array("i", [12694499, 12855016, 123457])',
  4. 'array("i", [12694499, 12865016, 123457])',
  5. 'array("i", [12694499, 12855016])',
  6. 'array("i", [12699749, 12877477])',
  7. 'array("i", [12828285, 12868277])',
  8. 'array("i", [-1])',
  9. 'array("i", [-1])',
  10. 'array("i", [-1])',
  11. 'array("i", [-12694499, -12865016, -123457])',]
  12.  
  13. for value in my_list:
  14. coords = re.search(r"\[-?[0-9]+(?:,\s-?[0-9]+)*]", value)
  15. if coords:
  16. print(coords.group())
Success #stdin #stdout 0.04s 9604KB
stdin
Standard input is empty
stdout
[12694499, 12855016, 123457]
[12694499, 12865016, 123457]
[12694499, 12855016]
[12699749, 12877477]
[12828285, 12868277]
[-1]
[-1]
[-1]
[-12694499, -12865016, -123457]