Home > Back-end >  How to write a regex that matches duplicated words with 5 occurrences?
How to write a regex that matches duplicated words with 5 occurrences?

Time:11-14

I want to match the duplicated words which in this instance is GHL_AutoMatchFaulted In this example, there are 5 occurrences which I want to match all 5 otherwise it will not match

GHL_AutoMatchFaulted
GHL_AutoMatchFaulted
GHL_AutoMatchFaulted
GHL_AutoMatchFaulted
GHL_AutoMatchFaulted

Is this possible?

Any help would be much appreciated. Thanks.

Tried almost all from the forum but nothing works.

CodePudding user response:

How about this one: ?

(GHL_AutoMatchFaulted\s?\n?){5}
  • Looks for the keyword GHL_AutoMatchFaulted
  • with an optional space \s?
  • and an optional carriage return \n?
  • for exactly 5 times {5}

As per Regex101

  • Related