Thanks to the help with my previous homework question Regex to match tags like <A>, <BB>, <CCC> but not <ABC>
, but now I have another homework question.
I need to match tags like <LOL>
, <LOLOLOL>
(3 uppercase letters, with repeatable last two letters), but not <lol>
(need to be uppercase).
Using the technique from the previous homework, I tried <[A-Z]([A-Z][A-Z])1*>
. This works, except there's an additional catch: the repeating part can be in mixed case!
So I need to also match <LOLolol>
, <LOLOLOlol>
, because it's 3 uppercase letters, with repeatable last two letters in mixed case. I know you can make a pattern case-insensitive with /i
, and that will let me match <LOLolol>
with the regex I have, but it will also now match <lololol>
, because the check for the first 3 letters are also case-insensitive.
So how do I do this? How can I check the first 3 letters case sensitively, and then the rest of the letters case-insensitively? Is this possible with regex?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…