grep [0-9] work in the same way as
To be precise
[0-9] is only guaranteed to be equivalent to
the regexp parser supports
[:digit:](i.e. if it does not, then the existing
[:digit:]probably doesn't do what you think it does), and:
the input character set is one such as ASCII where the only digits are the characters
9and they are adjacent. This might not be true in (e.g.) unicode (where the digits may include characters other than the digits
9), or even in other 8 bit character sets where
9may not be adjacent (as it happens in EBCDIC the digits
Examples of unicode exceptions are shown here. As you can see the set of unicode characters in the category 'Number, Digit, Decimal' includes rather more than the 10 ASCII digits matched by
[0-9]; it includes arabic indic, extended arabic, ngo, etc.
More information on numerals in unicode can be found here.
You can change
[0-9] - note
[:digit:] is inside
[…]. This depends on the encoding of the input. If it is ASCII, I don't think there will be a problem. With other encodings, the digits may not be contiguous, or the byte range maybe different. You could also miss special numbers in other writing systems.
'[:digit:]' is theoretically more portable, the advantage being that it would not depend on one's local character set clumping digits all together.
Related example: With '[:upper:]' vs '[A-Z]' there's no difference in ASCII, but there is a difference on an old IBM EBCDIC system, where '[A-Z]' would span 41 chars not 26, (EBCDIC codes 193-233) and would therefore match EBCDIC "}\" et al.