我正在尝试使用正则表达式 (re.split) 拆分字符串,但自从我使用正则表达式以来已经有一段时间了。
字符串看起来像:
string = '"first, element", second element, third element, "fourth, element", fifth element'
Run Code Online (Sandbox Code Playgroud)
我想在每个逗号上拆分字符串,除非子字符串用引号括起来。
输出应如下所示:
output = ['"first, element"', 'second element', 'third element', '"fourth, element"', 'fifth element']
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7463 次 |
| 最近记录: |