public static List < String > getWords ( String text ) { List < String > output = new ArrayList <> ( ) ; if ( isNullOrEmptyTrimmed ( text ) ) { return output ; } Pattern p = Pattern . compile ( "\\b\\p{L}+\\b" ) ; Matcher m = p . matcher ( text ) ; while ( m . find ( ) ) { output . add ( m . group ( ) ) ; } return output ; }
Extracts words from text removing non alpha characters