zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: PATCH: Update the description of S flag in the completion
Date: Tue, 03 Dec 2019 11:39:12 +0100	[thread overview]
Message-ID: <4702-1575369552.992754@BTqk.3315.8qcb> (raw)
In-Reply-To: <CAKc7PVDHqmBj5g3_JasumDnent5c71+-G5LhRq6LdTTuFeeEsQ@mail.gmail.com>

Sebastian Gniazdowski wrote:
> On that occasion, isn't this a bug?:
>
> ❯ str="ab##c#d"; print ${(S)str##\#}
> ab#c#d
> ❯ str="ab##c#d"; print ${(S)str##\##}
> ab##c#d
>
> Why no match at all in the second case?

It does not exhaustively find the longest match. It takes the first
possible match but matches that one greedily. The first possible match
is the empty string at the beginning of the string.

I think the following demonstrates how this works more clearly:

  % str="aXXbXXXXXXXXc"; print ${(S)str##X##}
  abXXXXXXXXc

This matches the shorter block of Xs between a and b and the greedyness
means that both Xs were matched. ${(S)str#X##} returns aXbXXXXXXXXc.

Oliver

      parent reply	other threads:[~2019-12-03 10:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-02  0:31 Sebastian Gniazdowski
2019-12-02  0:46 ` Sebastian Gniazdowski
2019-12-03  5:16   ` Sebastian Gniazdowski
2019-12-03  9:42     ` Peter Stephenson
2019-12-03 14:45       ` Sebastian Gniazdowski
2019-12-03 10:39   ` Oliver Kiddle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4702-1575369552.992754@BTqk.3315.8qcb \
    --to=okiddle@yahoo.co.uk \
    --cc=sgniazdowski@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).