Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Non-greedy matching (S-flag) behaving weird
- X-seq: zsh-users 23451
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Non-greedy matching (S-flag) behaving weird
- Date: Fri, 8 Jun 2018 14:30:12 +0100
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180608133017euoutp026b137c3b71d620411199a1407f4e4112~2MnjAIO1r1831318313euoutp02w
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1528464617; bh=CMURFtbPeGYBcZvzi1v1yJY2GbRAxuoxPjHzYXCDcWQ=; h=Date:From:To:Subject:In-Reply-To:References:From; b=jSZqJD+FbgGlze56tSU2IeiQdbRKVM21XJnzAdTncOnGl1r/j5IHa3IzVm2XSuMPJ TI+dMP8uZsUvLXXrgjDOFIqmk3RmkqhQIdHK+a0NV5SISW7R6Dcstev0Jj5vKbfKgX 5GVCZOD+wqmK3JpgBowRia1y9ICAGdnlEs2QrXQ8=
- In-reply-to: <CAKc7PVDQcSL2fkot2i6H3YVwcp=q=bQ2DohTdfPGn2p5idH2Sw@mail.gmail.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
- Organization: SCSC
- References: <CGME20180608064952epcas4p4e8890504ddaf097f8d0df1cb1e89d619@epcas4p4.samsung.com> <CAKc7PVDQcSL2fkot2i6H3YVwcp=q=bQ2DohTdfPGn2p5idH2Sw@mail.gmail.com>
On Fri, 8 Jun 2018 08:48:05 +0200
Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
> below subsitution is a really easy one. First parenthesis: anything
> preceding, second parenthesis: print|END|BEGIN, third parenthesis:
> anything that follows print|END etc.
>
> ~ __wrd2="echo abc | awk '{ print \$1 } END { print 'Finished' }'"
>
> ~
> __wrd2="${(S)__wrd2/(#b)(#s)(*)(BEGIN|END|print)(*)(#e)/${match[3]}}";
I think what you're trying to do is:
print ${__wrd2#*(BEGIN|END|print)}
(or some variation thereon).
This is now well defined --- there's only one expression matching
an arbitrary number of parameters, and you've explicitly told it to
shorten from the end of the string to resolve multiple matches.
You are onto a loser with multiple *'s with the greedy match rule
relaxed; it's poorly defined. so the fact it's not doing what you
expect isn't saying anything. (That's why the greedy match rule
is there in the first place.) But you'll be better off consulting
a more authoritative source than me if you want more, so I'll
sign off now.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author