擅长:python、mysql、java
<p>你可以试试下面的代码</p>
<pre><code>>>> import re
>>> string = '"first, element", second element, third element, "fourth, element", fifth element'
>>> m = re.split(r', (?=(?:"[^"]*?(?: [^"]*)*))|, (?=[^",]+(?:,|$))', string)
>>> m
['"first, element"', 'second element', 'third element, "fourth, element"', 'fifth element']
</code></pre>
<p><sub>Regex从<a href="https://stackoverflow.com/a/25471762/3297613">here</a>:-)</sub>被盗</p>