import re


def _filter_FR(ret, pattern):
    """
    Function to filter hosts by name using regex pattern search
    """

    # run filtering
    if isinstance(pattern, list):
        return ret.filter(
            filter_func=lambda h: any([re.search(str(p), h.name) for p in pattern])
        )
    else:
        return ret.filter(
            filter_func=lambda h: True if re.search(str(pattern), h.name) else False
        )