import re


def project_pattern_match(results, project_pattern):
    """
    Return projects which match the project pattern. No pattern specified returns all projects
    :param results - list of all projects
    :param project_pattern - optional wildcard (*) name of project to match
    :return: list of projects
    """

    if project_pattern:
        # convert wildcard "*" to regex format ".*"
        pattern = project_pattern.replace("*", ".*")
        compiled = re.compile(pattern)
        return [project for project in results if compiled.match(project['summary_fields']['project']['name'])]

    return results