private final static String basePhoneNumber ( String number ) throws ParseException { StringBuffer s = new StringBuffer ( ) ; Lexer lexer = new Lexer ( "sip_urlLexer" , number ) ; int lc = 0 ; while ( lexer . hasMoreChars ( ) ) { char w = lexer . lookAhead ( 0 ) ; if ( Lexer . isDigit ( w ) || w == ' ' || w == ' ' || w == ' ' || w == ' ' ) { lexer . consume ( 1 ) ; s . append ( w ) ; lc ++ ; } // else if (lc > 0) // break; else throw new IllegalArgumentException ( "unexpected " + w + " in the phone number" ) ; } return s . toString ( ) ; }
the part in comment