0

I am trying to make Chatterino (Twitch chat) warn me when the same message is sent over and over again. Chatterino uses REGEX PCRE2 flavor to check if pattern was sent in chat. ^bot\b == warning when someone typed the word "bot" once. I wanted to create a warning for repeated messages from different users. example:

user0: nice -->no warning
user1: nice -->warning

The warning should occur not only for the word nice, but for every word that is repeated in sequence Is it possible?

The wiki shows me these lines: x* x, repeated any number of times x+ x, repeated any number of times but at least 1

But from what I've noticed, it warns me when a x is repeated within the same message. I want the warning to occur when different messages are x

bobble bubble
  • 16,888
  • 3
  • 27
  • 46
  • See https://stackoverflow.com/questions/2823016/regular-expression-for-duplicate-words. In PCRE you can [capture](https://www.regular-expressions.info/brackets.html) a word and if you want to check for multiple duplicate words, you can use a lookahead to check if the captured word occurs again. Something like [`\b(\w+)\b(?=.+\b\1\b)`](https://regex101.com/r/I9sZWv/1) – bobble bubble Jan 19 '23 at 10:11
  • I tried that solution, but I couldn't change it so it would compare the words in other messages and not in the same line. Example: msg1="I like music" msg2="I like bananas" nothing is captured and that's what I'm after. The only case that code captures is "I like like music" not what I'm looking for. – Renan Tomisaki Jan 19 '23 at 15:50
  • To make it match across lines you need to prepend the `(?s)` flag like in the linked demo. If this is not available, you can use `[\s\S]+` instead of `.+` like [in this demo](https://regex101.com/r/I9sZWv/3). – bobble bubble Jan 19 '23 at 19:46

0 Answers0