On 05/15/2018 03:43 PM, Stephane Chazelas wrote:

Does that mean that [0-9] is also guaranteed to match on
0123456789 only? And that then [[:digit:]] in regexp/fnmatch is
close to useless as it's longer than [0-9]

Yes, I think that's a fair conclusion for the C locale, by virtue of the fact that the standard requires the encoding for 0-9 to be contiguous and in order.

and is a bit
misleading as it suggests it would be affected by localisation
(like the other character classes) while it's not.

It's still useful in non-C locales within regexp, since ALL uses of - for ranges within [] has unspecified (or was it implementation-defined) semantics outside of the C locale. Using a named reference guarantees the desired semantics of exactly 10 characters, rather than skirting on the grounds of whether the range operator behaves as desired in all locales rather than just the C locale.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Reply via email to