0 out of 464 challenges solved
Write a Python function `match_a_followed_by_b` that takes a string as input and returns `True` if the string contains an 'a' followed by one or more 'b's, and `False` otherwise. Use regular expressions to solve this problem. #### Example Usage ```python [main.nopy] print(match_a_followed_by_b("ab")) # Output: True print(match_a_followed_by_b("a")) # Output: False print(match_a_followed_by_b("abb")) # Output: True print(match_a_followed_by_b("b")) # Output: False ``` #### Constraints - The function should be case-sensitive. - The input string can be of any length, including empty.
import re def match_a_followed_by_b(text): """ Check if the input string contains an 'a' followed by one or more 'b's. Args: text (str): The input string to check. Returns: bool: True if the pattern is found, False otherwise. """ # Define the regular expression pattern pattern = '' # TODO: Add the correct regex pattern # Use re.search to find the pattern in the text return bool(re.search(pattern, text))