def create_regex_extractor(pattern):
 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]))
 _extractor.__name__ = ('Regex: %s' % pattern.encode('utf-8'))
 return _extractor

def create_regex_extractor ( pattern ) : 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 ] ) ) _extractor . __name__ = ( 'Regex: %s' % pattern . encode ( 'utf-8' ) ) return _extractor
create extractor from a regular expression .