# Write a function to find # sequences of lowercase letters joined with a underscore. # Example: # "aab_cbbbc" the function returns "Found a match!" # "aab_Abbbc" the function returns "Not matched!" # "Aaab_abbbc" the function returns "Not matched!" import re def text_match1(text): regex = re.compile(r'(^[a-z]+_[a-z]+$)') if regex.search(text): return 'Found a match!' else: return 'Not matched!' print(text_match1("aab_cbbbc")) print(text_match1("aab_Abbbc")) print(text_match1("Aaab_abbbc")) def text_match2(text): regex = re.compile(r'(^[a-z]+_[a-z]+$)') if len(regex.findall(text)) > 0: return 'Found a match!' else: return 'Not matched!' print(text_match2("aab_cbbbc")) print(text_match2("aab_Abbbc")) print(text_match2("Aaab_abbbc")) def text_match3(text): patterns = '^[a-z]+_[a-z]+$' if re.search(patterns, text): return 'Found a match!' else: return 'Not matched!' print(text_match3("aab_cbbbc")) print(text_match3("aab_Abbbc")) print(text_match3("Aaab_abbbc"))