import re


def from_pattern(pattern, name):
    """Helper function to find the common pattern among a group
    of like-named constants. eg if the pattern is FILE_ACCESS_*
    then the part of the name after FILE_ACCESS_ will be returned.
    """
    if pattern is None:
        return name
    else:
        return re.search(pattern.replace("*", r"(\w+)"), name).group(1)