Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: BUG: ${var##(|A)} fails to find longest prefix
- X-seq: zsh-workers 53598
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: BUG: ${var##(|A)} fails to find longest prefix
- Date: Mon, 12 May 2025 16:23:31 -0700
- Archived-at: <https://zsh.org/workers/53598>
- In-reply-to: <CAGdYchvMFzqoBz9cyN2nHa85n7EYaeN0bSKOf=c+jTKZksTJVA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYchujpGjntfLe7BsGWBsC0Zme7Tym8rqdq+rXxRL-dyrckw@mail.gmail.com> <CAH+w=7bQ5db_1opF7sosb0AhMFV_r1Lda4gLgBK=vaHux7qGkA@mail.gmail.com> <CAGdYchvMFzqoBz9cyN2nHa85n7EYaeN0bSKOf=c+jTKZksTJVA@mail.gmail.com>
On Mon, May 12, 2025 at 3:57 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>>
>> There's no backtracking for X|Y
>
> Really? But then why doesn't s=AA; echo ${s#(A|)A} print the empty string?
It doesn't matter whether you're looking for longest or shortest, X|Y
is always left to right. In the above (A|) will always match A, and
(|A) will always match the empty position before or between two
substrings. It'll only try the right branch if the left branch
doesn't match or if backtracking of the entire pattern rewinds to
before the open paren.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author