違いは何ですか:
[xyz]
[x|y|z]
もしあれば?[] と | の両方 代替案を指定します。
次のコードは、まったく同じ結果を出力します。
String string = "the x and the y and the z and the nothing";
evaluatePattern(Pattern.compile("\\w*[xyz]\\w*"), string);
evaluatePattern(Pattern.compile("\\w*[x|y|z]\\w*"), string);