-4
**(?i)\\b([a-z]+)\\b(?:\\s+\\1\\b)+**

I understand what each symbol means but when the symbols are combined...I can't figure out. The confusion part is (?:\s+\1\b)+. What does it mean??? Can you explain to me?? Thanks for your time!

Shar
  • 11
  • 1

1 Answers1

0

Individual parts of (?:\s+\1\b)+ have the following meaning:

  • (?:...) - a non-capturing group. It contains:
  • \s+ - a non-empty sequence of white space chars.
  • \1 - a backreference to capturing group #1 (\b([a-z]+)\b). It means that you want to have here just the same chars (the repeated word) which has been just captured.
  • \b - a word boundary, in this case transition from word area to space area.

After the whole above group there is a + sign, meaning that you want to match as many repeating words as possible.

Valdi_Bo
  • 24,530
  • 2
  • 17
  • 30