String maybeStripExtension(StringBuilder number){
  Matcher m=EXTN_PATTERN.matcher(number);
  if (m.find() && isViablePhoneNumber(number.substring(0,m.start()))) {
    for (int i=1, length=m.groupCount(); i <= length; i++) {
      if (m.group(i) != null) {
        String extension=m.group(i);
        number.delete(m.start(),number.length());
        return extension;
      }
    }
  }
  return "";
}

String maybeStripExtension ( StringBuilder number ) { Matcher m = EXTN_PATTERN . matcher ( number ) ; if ( m . find ( ) && isViablePhoneNumber ( number . substring ( 0 , m . start ( ) ) ) ) { for ( int i = 1 , length = m . groupCount ( ) ; i <= length ; i ++ ) { if ( m . group ( i ) != null ) { String extension = m . group ( i ) ; number . delete ( m . start ( ) , number . length ( ) ) ; return extension ; } } } return "" ; }
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 .
