Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: BUG: ${var##(|A)} fails to find longest prefix



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