I have a requirement that a name should not start with three identical letters ignoring their case. The name begins with an uppercase letter followed by lowercase letters.
Basically, I could convert the entire name to uppercase and then match the regular expression, for example (\p{Lu})\1{3,}.* .
But I was wondering if there is a regular expression that meets the above requirements, and does not need to preprocess the string that needs to be matched. So, what regular expression can be used to match strings like Aa , Dd or Uu without explicitly specifying any possible combination?
EDIT:
I accepted the answer of Marcos. I just needed to fix it to work with names of lengths 1 and 2 and bind it at the beginning. So the actual regex for my use case ^(\p{Lu})(\p{Ll}?$|(?=\p{Ll}{2})(?i)(?!(\1){2})) .
I also supported the answers of Eugene and sp00m for helping me learn a lesson in regular expressions.
Thank you for your efforts.
Spacetracker
source share