question: public static Pattern buildStopwordPattern ( Collection < String > stopwords , Boolean caseSensitive ) { StringJoiner sj = new StringJoiner ( "|" ) ; for ( String s : stopwords ) { sj . add ( Pattern . quote ( s ) ) ; } if ( caseSensitive ) { return Pattern . compile ( "\\b(" + sj . toString ( ) + ")\\b" ) ; } else { return Pattern . compile ( "\\b(" + sj . toString ( ) + ")\\b" , Pattern . CASE_INSENSITIVE ) ; } }
target:  Build a regular expression that will match any stopword