Is the regular expression [a-Z] valid and if yes then is it the same as [a-zA-Z]?
Please note that in [a-Z] the a
is lowercase and the Z is uppercase.
E
I've just fallen over this in a script (not my own).
It seems that grep, awk, sed accept [a-Z]
based on your locale (i.e. LANG or LC_CTYPE environment variable). In POSIX, [a-Z]
isn't allowed by these tools, but in some other locales (e.g. en_gb.utf8) it works, and is the same as [a-zA-Z]
.
Yes, I've checked, it doesn't match any of _^[]`
.
Given that this has taken quite some time to debug, I strongly discourage anyone from ever using [a-Z]
in a regex.