def apply_func_to_match_groups(match, func=icu_upper, handle_entities=handle_entities):
 found_groups = False
 i = 0
 (parts, pos) = ([], match.start())
 f = (lambda text: handle_entities(text, func))
 while True:
  i += 1
  try:
   (start, end) = match.span(i)
  except IndexError:
   break
  found_groups = True
  if (start > (-1)):
   parts.append(match.string[pos:start])
   parts.append(f(match.string[start:end]))
   pos = end
 if (not found_groups):
  return f(match.group())
 parts.append(match.string[pos:match.end()])
 return u''.join(parts)

def apply_func_to_match_groups ( match , func = icu_upper , handle_entities = handle_entities ) : found_groups = False i = 0 ( parts , pos ) = ( [ ] , match . start ( ) ) f = ( lambda text : handle_entities ( text , func ) ) while True : i += 1 try : ( start , end ) = match . span ( i ) except IndexError : break found_groups = True if ( start > ( - 1 ) ) : parts . append ( match . string [ pos : start ] ) parts . append ( f ( match . string [ start : end ] ) ) pos = end if ( not found_groups ) : return f ( match . group ( ) ) parts . append ( match . string [ pos : match . end ( ) ] ) return u'' . join ( parts )
apply the specified function to individual groups in the match object (the result of re .