Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: #% anchoring doesn't work with (S)
- X-seq: zsh-workers 51366
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: #% anchoring doesn't work with (S)
- Date: Mon, 6 Feb 2023 17:31:10 +0000 (GMT)
- Archived-at: <https://zsh.org/workers/51366>
- Importance: Normal
- In-reply-to: <CAH+w=7Z1BVw9s1PbNzonc5knGcSMRWYr7f2teuhEZOazOHKuNg@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAKc7PVA=Beup8-GyjpxCst0=Ne_-v1yjYqn46YuRMTRuvTpteg@mail.gmail.com> <CAKc7PVBi-_jW2UZkOaxpOqUG=V+DS8sU814nVp4Yj7Su28Kqpg@mail.gmail.com> <CAHYJk3R9UGo=UTo=brTqHQnmrxTHiRxaoN1Q_9QfN4LWrsk7gQ@mail.gmail.com> <CAKc7PVCqLLrq24Haa7JuUpvEdZz-VSujhsS=fdbhe37HqETBYw@mail.gmail.com> <CAH+w=7Z1BVw9s1PbNzonc5knGcSMRWYr7f2teuhEZOazOHKuNg@mail.gmail.com>
> On 06/02/2023 17:17 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Thu, Feb 2, 2023 at 4:49 AM Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> wrote:
> > On Thu, 2 Feb 2023 at 10:32, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> >>
> >> Why would you use (S) (shortest possible match) with #% (match the
> >> entire string)? It will obviously never have a useful effect other
> >> than doing nothing.
> >
> > It does have sense to match shortest and anchor to #%, it simply moves the "weight" on the right side of the pattern, i.e. "ABC" == (?)* vs ABC == *(?) (not very correct, but shows the thought).
>
> Arguably then this is wrong:
>
> % sample=match
> % : ${(S)sample/(#b)(#s)(m*)(*)(#e)}; printf "<%s>" $match ; echo
> <match>
>
> I expected <m><atch>. Compare without the end anchor:
>
> % : ${(S)sample/(#b)(#s)(m*)(*)}; printf "<%s>" $match ; echo
> <m>
>
> In any case the behavior of PWS's patch appears to be the same.
I haven't followed this through in detail, but I believe we just don't have
enough state in the matcher to deal with longest vs. shortest substring
at the same time as everything else.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author