fork download
  1. import re
  2. rx = r"(?:\([^()]*\)|[^,])+"
  3. s = 'test,Test,NEAR(this,that,DISTANCE=4),test again,"another test"'
  4. print(re.findall(rx, s))
  5.  
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
['test', 'Test', 'NEAR(this,that,DISTANCE=4)', 'test again', '"another test"']