code: def capture(self, pattern, name=None):
          
  
          if isinstance(pattern, basestring):
              pattern = re.compile(pattern)
  
          def munge(self, value):
              match = pattern.match(value)
              if not match:
                  return NONE
              for group in [name or self.name, 1]:
                  try:
                      return match.group(group)
                  except IndexError:
                      pass
              return NONE
  
          return self.munge.attach(self)(munge)
docs: Hooks munge to capture a value based on a regex.