cHa*_*TrU 3 python string split delimiter
假设我有一个字符串
"Let's split this string into many small ones"
,我希望将其拆分this,into并且ones
这样输出看起来像这样:
["Let's split", "this string", "into many small", "ones"]
Run Code Online (Sandbox Code Playgroud)
最有效的方法是什么?
Ign*_*ams 11
带着前瞻.
>>> re.split(r'\s(?=(?:this|into|ones)\b)', "Let's split this string into many small ones")
["Let's split", 'this string', 'into many small', 'ones']
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2538 次 |
| 最近记录: |