def find_forbidden_phrase(text): """returns string or None""" def norm_text(t): return ' '.join(t.split()).lower() forbidden_phrases = askbot_settings.FORBIDDEN_PHRASES.strip() text = norm_text(text) if forbidden_phrases: phrases = split_phrases(forbidden_phrases) for phrase in phrases: phrase = norm_text(phrase) if phrase in text: return phrase return None