擅长:python、mysql、java
<p>使用与<code>str.contains</code>匹配的正则表达式。在</p>
<pre><code>p = '|'.join(b['dirty_words'].dropna())
a[a['text'].str.contains(r'\b{}\b'.format(p))]
text
0 the cat jumped over the hat
2 i lost my dog in the fog
</code></pre>
<p>单词边界确保不会仅仅因为“catch”包含“cat”就匹配它(谢谢@DSM)。在</p>