1

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?

kReoSo
  • 209
  • 2
  • 4
  • 12
  • 2
    Dupe: http://stackoverflow.com/questions/1658844/is-the-regular-expression-a-z-valid-and-if-yes-then-is-it-the-same-as-a-za-z – 000 Apr 13 '12 at 19:04

1 Answers1

2

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].

Kashyap
  • 15,354
  • 13
  • 64
  • 103