Gets a list of :class:`language_tags.Subtag.Subtag` objects where the description matches.

        :param description: a string or compiled regular expression. For example: ``search(re.compile('\d{4}'))`` if the
            description of the returned subtag must contain four contiguous numerical digits.
        :type description: str or RegExp
        :param all: If set on True grandfathered and redundant tags will be included in the return
            list.
        :type all: bool, optional
        :return: list of :class:`language_tags.Subtag.Subtag` objects each including the description.
            The return list can be empty.

def search(description, all=False):
        """
        Gets a list of :class:`language_tags.Subtag.Subtag` objects where the description matches.

        :param description: a string or compiled regular expression. For example: ``search(re.compile('\d{4}'))`` if the
            description of the returned subtag must contain four contiguous numerical digits.
        :type description: str or RegExp
        :param all: If set on True grandfathered and redundant tags will be included in the return
            list.
        :type all: bool, optional
        :return: list of :class:`language_tags.Subtag.Subtag` objects each including the description.
            The return list can be empty.
        """

        # If the input query is all lowercase, make a case-insensitive match.
        if isinstance(description, str):
            list_to_string = lambda l: ', '.join(l).lower() if description.lower() == description else ', '.join(l)

            def test(record):
                return description in list_to_string(record['Description'])

        elif hasattr(description.search, '__call__'):
            def test(record):
                return description.search(', '.join(record['Description'])) is not None

        records = filter(lambda r: False if ('Subtag' not in r and not all) else test(r), registry)
        if six.PY3:
            records = list(records)
        # Sort by matched description string length. This is a quick way to push precise matches towards the top.
        results = sorted(records, key=lambda r: min([abs(len(r_description) - len(description))
                                                    for r_description in r['Description']])) \
            if isinstance(description, str) else records
        return [Subtag(r['Subtag'], r['Type']) if 'Subtag' in r else Tag(['Tag']) for r in results]