Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Non-greedy matching (S-flag) behaving weird
- X-seq: zsh-users 23449
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: Non-greedy matching (S-flag) behaving weird
- Date: Fri, 8 Jun 2018 14:42:34 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=8CTONhPlPA98H0ov0LctLqSg0ipD5yb0BdcYHWiUsfc=; b=r8mc2qdglZlg0U7KaJb9OAX8WiSNc1/eEyx3zoynBqepdjmuiaeGjs5WGqFDe9QMlN An4kowLCD6E/N4nwcdAYq9evqKcWvn0Bpg9i2N8oMfNViiH8ztx7vJEqU3vsHdNDhaaB IhvbPDAxGLCbmn1XmhkBd98X8Ony9QRl4HbYhePajshUbQwLjpFjVipfprwu5loGQfSz RtvhUlxNJkOW7kRE7M14CyL0ys75k1rk8rCRsannyuu2b2Jh3YUoA5+vUNRUivlnfxIE JdznZDDeqfO+YSTHO8M/QOI23qJf6/H8Z301m/m51mZ/01nyDg+8rbfCkFdpNzmpqssQ WsrQ==
- In-reply-to: <20180608081535eucas1p1cf8eab9e4500aaf73521e32a19df0bf5~2IUxfX6MX1459414594eucas1p15@eucas1p1.samsung.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CGME20180608064952epcas4p4e8890504ddaf097f8d0df1cb1e89d619@epcas4p4.samsung.com> <CAKc7PVDQcSL2fkot2i6H3YVwcp=q=bQ2DohTdfPGn2p5idH2Sw@mail.gmail.com> <20180608081535eucas1p1cf8eab9e4500aaf73521e32a19df0bf5~2IUxfX6MX1459414594eucas1p15@eucas1p1.samsung.com>
On 8 June 2018 at 10:15, Peter Stephenson <p.stephenson@xxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author