code: def _maybe_strip_extension(number):
      
      match = _EXTN_PATTERN.search(number)
      # If we find a potential extension, and the number preceding this is a
      # viable number, we assume it is an extension.
      if match and _is_viable_phone_number(number[:match.start()]):
          # The numbers are captured into groups in the regular expression.
          for group in match.groups():
              # We go through the capturing groups until we find one that
              # captured some digits. If none did, then we will return the empty
              # string.
              if group is not None:
                  return (group, number[:match.start()])
      return ("", number)
docs: Strip extension from the end of a number string.
  
      Strips any extension (as in, the part of the number dialled after the
      call is connected, usually indicated with extn, ext, x or similar) from
      the end of the number, and returns it.
  
      Arguments:
      number -- the non-normalized telephone number that we wish to strip the extension from.
  
      Returns a 2-tuple of:
       - the phone extension (or "" or not present)
       - the number before the extension.