更新时间:2023-02-10 14:18:25
这是一个解决方案,它使用带有 re.sub
方法的简单正则表达式.此解决方案还删除了数字.
Here is a solution, using simple regular expression with the re.sub
method. This solution removes numbers as well.
import re
abc=[ 'issues in performance 421',
'how are you doing',
'hey my name is abc, 143 what is your name',
'attention pleased',
'compliance installed 234']
stop=['attention\s+', 'installed\s+', '[0-9]']
[(lambda x: re.sub(r'|'.join(stop), '', x))(x) for x in abc]
'Output':
['issues in performance ',
'how are you doing',
'hey my name is abc, what is your name',
'pleased',
'compliance ']