Java Regex 2 - Duplicate Words

  • + 2 comments

    i found your statement helpful but in the question it is clearly mentioned that the input should be english alphabets or white spaces only, so the following works better.

    String regex = "\\b([a-z]|[A-Z]+)(\\s+\\1\\b)+";