擅长:python、mysql、java
<p>使用正则表达式。<code>re.split</code></p>
<p><strong>例如:</strong></p>
<pre><code>import re
l = ['match','regex','find']
_str = 'find the match and then find the regex later on'
print([i for i in re.split("("+"|".join(l)+ ")", _str) if i])
</code></pre>
<p><strong>输出:</strong></p>
<pre><code>['find', ' the ', 'match', ' and then ', 'find', ' the ', 'regex', ' later on']
</code></pre>