Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Non-greedy matching (S-flag) behaving weird
- X-seq: zsh-users 23448
- 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 09:15:34 +0100
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180608081537euoutp01023208b452e5544580f07e8a749860de~2IUzsGN9z1741217412euoutp01U
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1528445737; bh=fpAnikc1R49qoS16gPr2+tipiTwgfU03Lq2YxHFnHhI=; h=Date:From:To:Subject:In-Reply-To:References:From; b=C3/u051KsAuwyCFdN2gdVetDqw9Ngsx2sijTrisdRHKy2dz4nc8eiTL8AWfRLZGwO TPk0QjvTmSMtsD6GU/20RfBBXnY2VzwXXoOH+9Lc6pqo0ZGxIVpKeNaxHzkfDvznJZ qBI9b0+6JYF+id2uDtmfJwe7Zqb1QGbPcp7s6nU8=
- 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]}}";
>
> ~ echo "__wrd2: $__wrd2, match[1]: ${match[1]}, match[2]: ${match[2]},
> match[3]: ${match[3]}"; echo $?
>
> __wrd2: 'Finished' }', match[1]: echo abc | awk '{ print $1 } END { ,
> match[2]: print, match[3]: 'Finished' }'
>
> As it can be seen, match[1] obtains almost whole string. The matching
> is ungreedy, why `print' isn't matched? Why matching continues to last
> keyword, "END", skipping "print"
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.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author