[ create a new paste ] login | about

Link: http://codepad.org/B4DJCwW2    [ raw code | output | fork ]

Python, pasted on Oct 13:
1
2
3
4
5
6
7
8
9
10
11
import re

definiciones= ['infectado', 'contagio', 'bicho', 'malware', 'maluco', 'virus']
string="string infectado con virus o un bicho maluco que causa contagio como tal como un malware "



remove = "|".join(definiciones)
regex = re.compile(r'\b('+remove+r')\b', flags=re.IGNORECASE)
string_limpio = regex.sub("", string)
print("*String Libre de Virus;*", string_limpio)


Output:
1
('*String Libre de Virus;*', 'string  con  o un   que causa  como tal como un  ')


Create a new paste based on this one


Comments: