Regex matches uppercase characters to uppercase letters
I am using notepad ++ and I find that when I use a regex to search for strings where I specifically want to find lowercase letters ("[az]"), it sometimes returns uppercase letters.
I was originally looking for the line:
^[A-Z][a-z].+?$
For the purpose of deleting any line in my file that starts with an uppercase character, it is followed by a lowercase letter, followed by anything to the end of the line. However, this returned strings like "CLONE" and "DISEASE" which were only in capital letters. Out of curiosity, I tried:
^[a-z].+?$
And he still got those lines back in all the caps. Finally, I tried:
^[\u0061-\u007A].+?$
And it still returns the text lines of all headers. Is there something outside of my parentheses that is causing this?
source to share
Like many other text editors, Notepad ++ provides a global option Match case
. Even if your expression does not contain an internal modifier (?i)
, the results may be unexpected depending on whether it is Match case
ON or OFF.
So your ALLCAPS strings are valid for ^[A-Z][a-z].+?$
.
Check Match case
to turn on case sensitivity for regular expression searches:
source to share