Java tutorial
import java.text.BreakIterator; import java.util.Locale; public class Main { public static void main(String[] args) { String text = "this is a test(this is a test)."; BreakIterator wordIterator = BreakIterator.getWordInstance(Locale.getDefault()); extractWords(text, wordIterator); } static void extractWords(String target, BreakIterator wordIterator) { wordIterator.setText(target); int start = wordIterator.first(); int end = wordIterator.next(); while (end != BreakIterator.DONE) { String word = target.substring(start, end); if (Character.isLetterOrDigit(word.charAt(0))) { System.out.println(word); } start = end; end = wordIterator.next(); } } }