def _sub(self, mo):
        '''
        determine which partial regex matched, and
        dispatch on self accordingly.
        '''
        for k,v in mo.groupdict().iteritems():
            if v:
                sub = getattr(self, k)
                if callable(sub):
                    return sub(mo)
                return sub
        raise AttributeError, \
             'nothing captured, matching sub-regex could not be identified'

        determine which partial regex matched, and
        dispatch on self accordingly.
        
recipes/Python/576710_MultiRegex_Single_pass_replace_multiple/recipe-576710.py