'Perform a regex search on the given string, using a single or a list of
patterns returning the first matching group.
In case of failure return a default value or raise a WARNING or a
RegexNotFoundError, depending on fatal, specifying the field name.'

def _search_regex(self, pattern, string, name, default=NO_DEFAULT, fatal=True, flags=0, group=None):

    if isinstance(pattern, (str, compat_str, compiled_regex_type)):
        mobj = re.search(pattern, string, flags)
    else:
        for p in pattern:
            mobj = re.search(p, string, flags)
            if mobj:
                break
    if ((not self._downloader.params.get(u'no_color')) and (compat_os_name != u'nt') and sys.stderr.isatty()):
        _name = (u'\x1b[0;34m%s\x1b[0m' % name)
    else:
        _name = name
    if mobj:
        if (group is None):
            return next((g for g in mobj.groups() if (g is not None)))
        else:
            return mobj.group(group)
    elif (default is not NO_DEFAULT):
        return default
    elif fatal:
        raise RegexNotFoundError((u'Unable    to    extract    %s' % _name))
    else:
        self._downloader.report_warning(((u'unable    to    extract    %s' % _name) + bug_reports_message()))
        return None
