

def _maybe_strip_extension(number):
    'Strip extension from the end of a number string.\n\n    Strips any extension (as in, the part of the number dialled after the\n    call is connected, usually indicated with extn, ext, x or similar) from\n    the end of the number, and returns it.\n\n    Arguments:\n    number -- the non-normalized telephone number that we wish to strip the extension from.\n\n    Returns a 2-tuple of:\n     - the phone extension (or "" or not present)\n     - the number before the extension.\n    '
    match = _EXTN_PATTERN.search(number)
    if (match and _is_viable_phone_number(number[:match.start()])):
        for group in match.groups():
            if (group is not None):
                return (group, number[:match.start()])
    return ('', number)

dataset/ETHPy150Open daviddrysdale/python-phonenumbers/python/phonenumbers/phonenumberutil.py _maybe_strip_extension/original