(?i) - case insensitive flag
\\b - word boundary
(\\w+) - 1 or more word characters (A-Z, a-z, 0-9) in a captured group
\\b - word boundary
[\\w\\W]* - 0 or more word or non-word characters
\\b - word boundary
\\1 - the group previously captured
\\b - word boundary
You may want to look at the Java tutorials for Regular Expressions. All these are explained there.
Multiple uses of Boundary
If you look at the Java tutorial for Boundary Matchers you will see what it is matching, i.e. a boundary of a word. Since this is looking for duplicate words it is making sure that the match is indeed the entire word and not words containing the word.
Case Insensitive
As mentioned by Phsemo this is used so that the \\1
matching group with still match if the case is different. i.e consider if the first word in a sentence was repeated.
Use of [\\w\\W]*
Again as mentioned by Phsemo this is probably used in place of .
(which is a regex special character for any character, except this is not guaranteed to match newline characters See this. .*
could be used in place of this if the dotall flag (?s)
was also included) so that newline characters are matched. And the quantifier of *
(0 or more) so that if the next word is a duplicate then it is matched and also if there are words/characters in between the duplicates they are matched.