I saw this as an answer for finding repeated words in a string. But when I use it, it thinks This and is are the same and deletes the is
This
is
I believe this is the regular expression you should be using to detect 2 consecutive words separated by any number of non-word characters:
Pattern p = Pattern.compile("\\b(\\w+)\\b\\W+\\b\\1\\b", Pattern.CASE_INSENSITIVE);