Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [Bug] S-flag imposes non-greedy match where it shouldn't
Or rather not a bug… It seems that it's the result of how % searches
the substrings from the end – it stops at the first match, i.e.: after
finding a first X from the right.
On Wed, 18 Dec 2019 at 21:41, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> Hi,
> str="aXXXXXbXXXXc"; print ${(S)str##X##}
> Output: abXXXXc
>
> As it can be seen, the flag worked correctly. However, when %% will be
> used instead of ##:
>
> str="aXXXXXbXXXXc"; print ${(S)str%%X##}
> Output: aXXXXXbXXXc
>
> Then the (S) flag seems to impose also non-greedy matching, not only
> substring searching.
> --
> Sebastian Gniazdowski
> News: https://twitter.com/ZdharmaI
> IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
> Blog: http://zdharma.org
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author