import re


def _re_match(pattern, s, flags=0):
    """
    Helper function for tests. Return either the full match via 
    re.MatchObject.group() or None if there was no match.
    
    'flags' is passed to re.search().
    """
    match = re.search(pattern, s, flags)
    
    if match is None:
        return None
    else:
        return match.group()