static int[] findNanpPhoneNumbers(CharSequence text){
  ArrayList<Integer> list=new ArrayList<Integer>();
  int startPos=0;
  int endPos=text.length() - NANP_MIN_DIGITS + 1;
  if (endPos < 0) {
    return new int[]{};
  }
  while (startPos < endPos) {
    while (Character.isWhitespace(text.charAt(startPos)) && startPos < endPos) {
      startPos++;
    }
    if (startPos == endPos) {
      break;
    }
    int matchEnd=findNanpMatchEnd(text,startPos);
    if (matchEnd > startPos) {
      list.add(startPos);
      list.add(matchEnd);
      startPos=matchEnd;
    }
 else {
      while (!Character.isWhitespace(text.charAt(startPos)) && startPos < endPos) {
        startPos++;
      }
    }
  }
  int[] result=new int[list.size()];
  for (int i=list.size() - 1; i >= 0; i--) {
    result[i]=list.get(i);
  }
  return result;
}

static int [ ] findNanpPhoneNumbers ( CharSequence text ) { ArrayList < Integer > list = new ArrayList < Integer > ( ) ; int startPos = 0 ; int endPos = text . length ( ) - NANP_MIN_DIGITS + 1 ; if ( endPos < 0 ) { return new int [ ] { } ; } while ( startPos < endPos ) { while ( Character . isWhitespace ( text . charAt ( startPos ) ) && startPos < endPos ) { startPos ++ ; } if ( startPos == endPos ) { break ; } int matchEnd = findNanpMatchEnd ( text , startPos ) ; if ( matchEnd > startPos ) { list . add ( startPos ) ; list . add ( matchEnd ) ; startPos = matchEnd ; } else { while ( ! Character . isWhitespace ( text . charAt ( startPos ) ) && startPos < endPos ) { startPos ++ ; } } } int [ ] result = new int [ list . size ( ) ] ; for ( int i = list . size ( ) - 1 ; i >= 0 ; i -- ) { result [ i ] = list . get ( i ) ; } return result ; }
finds north american numbering plan ( nanp ) phone numbers in the input text .
