Home > Software engineering >  Regex for matching a word with two ore more capital letters li
Regex for matching a word with two ore more capital letters li

Time:12-04

I'm trying to filter out words with multiple capital letters in cyrillic like in this example in google sheets:

ПредметыПапкиВзаимодействий

I've tried this one: \w*[А-Я]\w*[А–Я]\w

But it's only showing acronyms like ЭДО, ЕГАИС, etc.

Could you suggest any solutions?

CodePudding user response:

You can use

[А-ЯЁ][^А-ЯЁ]*[А-ЯЁ]

Or, if there can/should be no whitespaces between two capital letters you can use

[А-ЯЁ][^А-ЯЁ\s]*[А-ЯЁ]

Details:

  • [А-ЯЁ] - uppercase Russian letters
  • [^А-ЯЁ\s]* - any zero or more chars other than Russian uppercase letters and whitespace
  • [А-ЯЁ] - uppercase Russian letters
  • Related