[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: String substitution bug
From: |
Martin D Kealey |
Subject: |
Re: String substitution bug |
Date: |
Sun, 24 Nov 2024 22:51:43 +1000 |
On Sun, 24 Nov 2024 at 18:05, Andreas Kähäri <andreas.kahari@abc.se> wrote:
> I think the manual is quite clear:
>
> Within [ and ], character classes can be specified
> using the syntax [:class:], where class is one of the
> following classes defined in the POSIX standard:
> alnum alpha ascii blank cntrl digit graph lower print
> punct space upper word xdigit
>
> It says that the syntax "[:class:]" may be used within "[" and "]".
>
When one already knows how it works, that's obvious, and it's hard to see
how it could mean anything else.
When one *doesn't *already know how it works, “using the syntax *[:class:]*”
could just as easily mean using *:class:* inside *[…]*.
(This ambiguity is largely because it does not specify whether *[:class:]*
is the syntax for a character class, or the syntax for a bracket expression
containing a character class. It isn't helped by the phrase “*within [ and
]*”, which is pretty silly; its most literal reading in English means
“putting something in [ and putting something in ]”, both of which are
impossible. The intention is of course “*between [ and ]*” but that's
slightly ambiguous; I would suggest “*within a bracket expression*”, since
that's what it's called in POSIX §9.3.5 RE Bracket Expression
<https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap09.html#tag_09_03_05>
and in POSIX §2.14.1 Patterns Matching a Single Character
<https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_14_01>
2.14x
<https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_14_02>.
Or if that's not clear enough, “*within a […] bracket expression*”.)
This REALLY needs to be driven home both in the explanation and with
examples, preferably with at least one that illustrates using more than one
character class inside one match group.
How about this:
Within a […] bracket expression, character classes can be specified using
> the class syntax *[:class:]* (giving a bracket expression syntax of *[*…
> *[:class:]*…*]*), where *class* is one of the following classes defined
> in the POSIX standard:
> - *alnum* *alpha* *ascii* *blank* *cntrl* *digit* *graph* *lower*
> *print* *punct* *space* *upper* *word* *xdigit*
>
> There is no limit on the number or order of symbols, range expressions,
> character classes, and equivalence classes that can be used in one […]
> bracket expression. For example *[@[:digit:]#[=c=]$F-L]* will match any
> one of:
>
> - the symbols ‘@’, ‘#’, & ‘$’; or
> - the decimal digits; or
> - the symbols that are “equivalent” to ‘c’ according to the current
> locale
> (in addition to 'c' itself, this typically includes 'C', but may also
> include accented variants such as 'ç', 'Ç', 'č', & 'Č');
> or
> - the (upper-case) letters ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, & ‘L’.
>
> -Martin
- String substitution bug, marcel.plch, 2024/11/23
- Re: String substitution bug, Lawrence Velázquez, 2024/11/23
- Re: String substitution bug, marcel.plch, 2024/11/23
- Re: String substitution bug, Andreas Kähäri, 2024/11/24
- Re: String substitution bug,
Martin D Kealey <=
- Re: String substitution bug, Oğuz, 2024/11/24
- Re: String substitution bug, Martin D Kealey, 2024/11/25
- Re: String substitution bug, Zachary Santer, 2024/11/25
- Re: String substitution bug, Martin D Kealey, 2024/11/25
- Re: String substitution bug, Mike Jonkmans, 2024/11/26
- Re: String substitution bug, Zachary Santer, 2024/11/26
- Re: String substitution bug, Greg Wooledge, 2024/11/24
- Re: String substitution bug, Andreas Kähäri, 2024/11/24
- Re: String substitution bug, Lawrence Velázquez, 2024/11/24
- Re: String substitution bug, Andreas Kähäri, 2024/11/25