Thanks, Roman. I can break words from sentences -
String sentence=null; String target="Dog is a Dog and Cat is a Cat"; int index = 0; Locale currentLocale = new Locale ("en","US"); BreakIterator wordIterator = BreakIterator.getWordInstance(currentLocale); //Creating the sentence iterator BreakIterator bi = BreakIterator.getSentenceInstance(); bi.setText(target); while (bi.next() != BreakIterator.DONE) { sentence = target.substring(index, bi.current()); System.out.println(sentence); wordIterator.setText(sentence); int start = wordIterator.first(); int end = wordIterator.next(); while (end!=BreakIterator.DONE){ String word = sentence.substring(start,end); if (Character.isLetterOrDigit(word.charAt(0))) { System.out.println(word); }//if (Character.isLetterOrDigit(word.charAt(0))) start = end; end = wordIterator.next(); }//while (end!=BreakIterator.DONE) index = bi.current(); } // while (bi.next() != BreakIterator.DONE)
But did not get two other points. Thanks.
Rushdi shams
source share