What is the exact difference between these regular expressions?
First:
\\b(\\w+) \\1\\b
Second:
\\b(\\w+)\\1\\b
Third:
\\b(\\w+) \\1
What is the exact difference between these regular expressions?
First:
\\b(\\w+) \\1\\b
Second:
\\b(\\w+)\\1\\b
Third:
\\b(\\w+) \\1
\\b(\\w+) \\1\\b
matches a word, a space, and the same word again, flanked by word boundaries. For instance, it would match "a a" in "a a ", but would not match anything in "aa-", "aab", or "a ab".
\\b(\\w+)\\1\\b
matches a word, and the same word again, flanked by word boundaries. For instance, it would match "aa", in "aa-" but would not match anything in "aab" or "a a".
\\b(\\w+) \\1
matches a word, a space, and the same word again, but only needs a word boundary at the start. For instance, it would match "a a" in "a ab", but nothing in "aa" or "aab"