4 ms·
I'm sure POSIX thought about this a lot more than I have, so I'm probably missing something and am about to say something that is actually stupid, but... It sh
by tzs 8y ago
I'm sure POSIX thought about this a lot more than I have, so I'm probably missing something and am about to say something that is actually stupid, but...
It should overload items of the form "x-y" in ranges where x and y are single characters in the locale in use. It should define specific items of this form as not being ranges but simply shorthand for certain predefined strings. The expression is treated as if those items were replaced by the corresponding predefined strings before the regular expression was parsed.
In particular "a-z" => "abcdefghijklmnopqrstuvwxyz". Similar for uppercase. Include such a definition to produce each possible substring of length 2 or more of "abcdefghijklmnopqrstuvwxyz". Similar for "0-9".
- raverbashing 8y agoI'm not sure what you're saying, when would that be different from what we have today? I don't see why that would be beneficial. You also might want ranges as [a-fk-z] (for example)
- tzs 8y ago> I'm not sure what you're saying, when would that be different from what we have today? The situation today is that "[a-z]" is undefined by POSIX if you are not in the POSIX locale. I'm suggesting that it, and similar cases, should be made defined in all locales that include a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, and z. > You also might want ranges as [a-fk-z] (for example) Looking back, I wrote unclearly. Where I wrote 'overload items of the form "x-y" in ranges' it would have been better to write 'overload items of the form "x-y" inside bracket expressions'. In "[a-fk-z]" there are two items of that form. Under my suggestions, "a-f" would be replaced with "abcdef" in all locales, and "k-z" would be replaced with "klmnopqrstuvwxyz", giving "[abcdefklmnopqrstuvwxyz]".
- bonzini 8y agoBut would a-z also include for example à and ä, or should 0-9 include ½? (The solution that glibc will implement is to un-interleave lowercase and uppercase characters whenever the collation order is like aàAÀbBcC...).
- bewuethr 8y agoPerl more or less does that [1]: > Perl also guarantees that the ranges A-Z, a-z, 0-9, and any subranges of these match what an English-only speaker would expect them to match on any platform. [1]: https://perldoc.pl/perlrecharclass#Character-Ranges https://perldoc.pl/perlrecharclass#Character-Ranges