Reputation: 209
I thought [x-y] matches all characters from ascii code of x to ascii code of y. So, [A-z] should be any characters from 65 to 122. But grep in bash says 'Invalid range' and [a-Z] is correct for all alphabets, which in range from 97 to 90 in ascii code.
How exactly behaves in grep in such a case? And generally, [x-y] is nothing to do with ascii code in regexp?
Upvotes: 1
Views: 1127
Reputation: 17466
regex(5) doesn't say anything abt the implementation. [a-Z]
can be interpreted in other ways too (see joe's comment) (122-65+1)= 58 != 26*2
=> There are other chars you would be including IF someone implemented [a-Z]
the way you wanted.
Anyway, bottom line is grep doesn't allow it, regex(5) doesn't enforce it.
So just use [a-zA-Z]
.
Upvotes: 2