zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Non-greedy matching (S-flag) behaving weird
Date: Fri, 8 Jun 2018 14:42:34 +0200	[thread overview]
Message-ID: <CAKc7PVA361wW_4iQL4B5wwJM1q8pdD67BJyBtxGk33q=95SDHA@mail.gmail.com> (raw)
In-Reply-To: <20180608081535eucas1p1cf8eab9e4500aaf73521e32a19df0bf5~2IUxfX6MX1459414594eucas1p15@eucas1p1.samsung.com>

On 8 June 2018 at 10:15, Peter Stephenson <p.stephenson@samsung.com> wrote:
> You've got a "*" at the beginning and the end  They're both doing
> matching --- they're is no single "matching" to which a rule applies ,
> there are just separate patterns all attempting to match.  You're going
> to have to work out some way of forcing one of them to match more than
> the other.

You are apparently right, but it is a big surprise to me. * matching
over what (a|b) should match, on string xxxaxxxb?? Well, this test
works like I would expect:

~ buf='xxxaxxxbxxx'; print "${(S)buf/(#b)(*)(a|b)(*)/R}"
Rxxxbxxx

With greedy search (no (S)-flag):

~ buf='xxxaxxxbxxx'; print "${buf/(#b)(*)(a|b)(*)/R}"
R

However, I also tested vim, entering text:

abcd BEGIN efgh END ijkl

And then running matching with regex: .\{-}\(BEGIN\|END\).\{-}

\{-} is non-greedy match. YET, this matched till END, not till BEGIN.
Very weird.

-- 
Best regards,
Sebastian Gniazdowski


  reply	other threads:[~2018-06-08 12:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180608064952epcas4p4e8890504ddaf097f8d0df1cb1e89d619@epcas4p4.samsung.com>
2018-06-08  6:48 ` Sebastian Gniazdowski
2018-06-08  8:15   ` Peter Stephenson
2018-06-08 12:42     ` Sebastian Gniazdowski [this message]
2018-06-08 12:48       ` Sebastian Gniazdowski
2018-06-08 13:30   ` Peter Stephenson
     [not found]   ` <20180608143012.394398bf@camnpupstephen.cam.scsc.local>
2018-06-08 13:54     ` Peter Stephenson

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='CAKc7PVA361wW_4iQL4B5wwJM1q8pdD67BJyBtxGk33q=95SDHA@mail.gmail.com' \
    --to=sgniazdowski@gmail.com \
    --cc=p.stephenson@samsung.com \
    --cc=zsh-users@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).