If PhoneNumberUtil is asked to parse a number containing an extension, it fails to recognize the extension for nearly all extension formats ('x', 'ext.', '#', etc.).
The problem is that the initialization functions in getInstance() are called in the wrong order. self::initCapturingExtnDigits() needs to be called before self::initExtnPatterns(). Otherwise the extension patterns are created using a blank value for self::$CAPTURING_EXTN_DIGITS, i.e., the part of the pattern that is supposed to match the extension number is missing.
One of the attached commits fixes this issue. The other commit incorporates several bug fixes previously posted by resscode.
If PhoneNumberUtil is asked to parse a number containing an extension, it fails to recognize the extension for nearly all extension formats ('x', 'ext.', '#', etc.).
The problem is that the initialization functions in getInstance() are called in the wrong order. self::initCapturingExtnDigits() needs to be called before self::initExtnPatterns(). Otherwise the extension patterns are created using a blank value for self::$CAPTURING_EXTN_DIGITS, i.e., the part of the pattern that is supposed to match the extension number is missing.
One of the attached commits fixes this issue. The other commit incorporates several bug fixes previously posted by resscode.