def create_regex_extractor(pattern):
    r"""Create extractor from a regular expression.

    Only groups from match are extracted and concatenated, so it
    is required to define at least one group. Ex:
    >>> extractor = create_regex_extractor("(\d+).*(\.\d+)")
    >>> extractor(u"The price is <b>45</b></i class='sm'>.50</i> $")
    u'45.50'
    """
    ereg = re.compile(pattern, re.S)

    def _extractor(txt, htmlpage=None):
        if txt is None:
            return
        m = ereg.search(txt)
        if m:
            return htmlregion(u"".join([g for g in m.groups() or m.group()
                                        if g]))

    name = u"Regex: %s" % pattern
    if six.PY2:
        name = name.encode('utf-8')
    _extractor.__name__ = name
    return _extractor
Create extractor from a regular expression.

    Only groups from match are extracted and concatenated, so it
    is required to define at least one group. Ex:
    >>> extractor = create_regex_extractor("(\d+).*(\.\d+)")
    >>> extractor(u"The price is <b>45</b></i class='sm'>.50</i> $")
    u'45.50'
    
slybot/slybot/extractors.py