Stuff
public java v1 · immutable StringBuilder terms = new StringBuilder(); for (int i = 0; i < searchWords.length; i++) { terms.append(Pattern.quote(searchWords[i])); if (i + 1 < searchWords.length) { terms.append('|'); } }//here i would remove the last | from the end pSearch = Pattern.compile("(^|[\s,.!]+)" + terms.toString() + "([\s,.!]+|$)", Pattern.CASE_INSENSITIVE /*| Pattern.UNICODE_CASE*/);