擅长:python、mysql、java
<p>可以用<a href="https://docs.python.org/3.4/library/re.html" rel="nofollow">regex</a>替换<a href="https://docs.python.org/3.4/library/re.html#re.sub" rel="nofollow">^{<cd1>}</a>。你知道吗</p>
<pre><code>import re
pattern = '[^a-zA-Z\s]|(?i)archived'
results = [re.sub(pattern, '', s).strip() for s in product_pool]
# ['BUMP STOPPER RAZOR BUMP TREATMENT SENSITIVE SKIN FORMULA',
# 'WCS Cell phone Triangle wand sections lip gloss',
# 'SOS Steel Wool Soap Pads',
# 'HTH Spa pH Increaser',
# 'GLUE STICKS',
# 'F Splash Windshield Washer Fluid',
# 'Fingrs Mighty Drop g',
# 'Brush On Nail Glue Three Bond TB',
# 'Aveeno Continuous Protection Sunblock Spray Products']
</code></pre>
<p>正则表达式模式<code>[^...]</code>匹配任何不在<code>...</code>中的内容。然后可以使用<code>re.sub</code>将所有这些匹配项替换为空字符串,从而有效地删除它们。模式的第二项匹配<code>archived</code>块,<code>(?i)</code>告诉它忽略这些块的大小写。你知道吗</p>