In Java, when doing a replaceAll to look for a regex pattern like:
replaceAll(\"\\\\?i\\\\b(\\\\w+)\\\\b(\\\\s+\\\\1)+\\\\b\", \"$1\");
(t
You also can lead your initial string, which you are going to check for pattern matching, to lower case. And use in your pattern lower case symbols respectively.