Steffen Nurpmeso wrote, on 24 Sep 2024:
>
> Geoff Clare wrote in
>  <ZvGKHOb0E3IZ5Y4Q@localhost>:
> 
>  |I think this is required by the normative text (elsewhere than the
>  |grammar), not assumed by the example as Mike says.  The relevant text
>  |is in the definition of "matched" in 9.1:
>  |
>  |    Consistent with the whole match being the longest of the leftmost
>  |    matches, each subpattern, from left to right, shall match the
>  |    longest possible string.
> 
> Yes, that is good.
> 
>  |and it goes on to give an example:
>  |
>  |    For example, matching the BRE "\(.*\).*" against "abcdef", the
>  |    subexpression "(\1)" is "abcdef"
> 
> And really in that paragraph there are only successful matches,
> even 'and matching the BRE "\(a*\)*" against "bc", the
> subexpression "(\1)" is the null string' is so.  This text is,
> like shell field splitting etc, nothing for the occasional
> "standard text hopper", but can truly be read in full context
> only.

Thinking some more about that text, I see a problem. Since it
specifically talks about subpatterns, it could be read as implying
that subpatterns are maximised at the expense of parts that are not
in subpatterns.  Modifying the example to matching ".*\(.*\)" against
"abcdef", this interpretation would mean that the subpattern matches
the longest possible string, which is "abcdef", with the initial ".*"
matching nothing.  However, all the implementations I tried give the
expected null match for the subpattern.

-- 
Geoff Clare <g.cl...@opengroup.org>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England

Reply via email to