RedditPP Mascot

RedditPP

r/regex • … • u/DerPazzo

Match consecutive repetitions

Hi,

Flavor: .NET

What am I missing in this Regex to make sure it matches consecutive repetitions but only for full words, including any non-word character.

I got it working for most strings, but it does match a string it should not…

`(.+)\W\1`

[https://regex101.com/r/LA60nK/1](https://regex101.com/r/LA60nK/1)

The last string should not match as the matching string ends inmidst of a word.

Solution by -mbf: `(.+(?!\w))\W?\1(?!\w)`

— 0