有效地在多个字符串分隔符上拆分python字符串

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)