I’m trying to create a regex pattern that follows the rules:
- All occurrence of the letters E, I, L must be capital strictly.
- All other letters must strictly be lowercase.
I’m working with this rule ^[^eil]*[eil][^eil]*$
but having all capital letters also accepts the string.
2
Answers
/^[^eil]*[EIL][^eil]*$/g
appears to work on regexr.com using the string:EdIt thE ExprEssIon & tExt to sEE matchEs.L
Changing E, I or L to lowercase will not match any more, as you are expecting.
Notably, you must be running the operation in a case sensitive manner. Since you are doing case sensitive operations, you need
[EIL]
in the regex string to find those uppercase letters.You might use a match for only
E
I
L
, lowercase chars a-z withoute
i
l
plus digits_
and non word charactersW
Regex demo