Regex Failure - Bug Fixing #2
Oh no, Timmy's received some hate mail recently but he knows better. Help Timmy fix his regex filter so he can be awesome again!

Source: codewars | Difficulty: EASY

Starter code: def filter_words(phrase):
	

Solutions:
import re

def filter_words(phrase):
	return re.sub('(bad|mean|ugly|horrible|hideous)', 'awesome', phrase, flags=re.IGNORECASE)


from re import sub

def filter_words(phrase):
	return sub('(?i)(bad|mean|ugly|horrible|hideous)', 'awesome', phrase)


from re import sub, I

def filter_words(phrase):
	return sub('(bad|mean|ugly|horrible|hideous)', 'awesome', phrase, flags=I)


import re
BAD_WORD = re.compile('bad|mean|ugly|horrible|hideous', re.I)
GOOD_WORD = 'awesome'

def filter_words(phrase):
	return BAD_WORD.sub(GOOD_WORD, phrase)


def filter_words(s):
	sl = s.lower()
	while any((w in sl for w in ('bad', 'mean', 'ugly', 'horrible', 'hideous'))):
		for w in ('bad', 'mean', 'ugly', 'horrible', 'hideous'):
			if w in sl:
				i = sl.find(w)
				s = s[:i] + 'awesome' + s[i + len(w):]
				sl = s.lower()
	print(s)
	return s


import re
insults_regexp = re.compile('(bad|mean|ugly|horrible|hideous)', re.IGNORECASE)

def filter_words(phrase):
	return insults_regexp.sub('awesome', phrase)


from re import sub, I
filter_words = lambda phrase: sub('(bad|mean|ugly|horrible|hideous)', 'awesome', phrase, 0, I)