zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Non-greedy matching (S-flag) behaving weird
Date: Fri, 8 Jun 2018 14:30:12 +0100	[thread overview]
Message-ID: <20180608133014eucas1p1e9e52b0b4584862e5abeff6f51fab5d4~2MngR8fDf0722407224eucas1p1U@eucas1p1.samsung.com> (raw)
In-Reply-To: <CAKc7PVDQcSL2fkot2i6H3YVwcp=q=bQ2DohTdfPGn2p5idH2Sw@mail.gmail.com>

On Fri, 8 Jun 2018 08:48:05 +0200
Sebastian Gniazdowski <sgniazdowski@gmail.com> 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


  parent reply	other threads:[~2018-06-08 13:39 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
2018-06-08 12:48       ` Sebastian Gniazdowski
2018-06-08 13:30   ` Peter Stephenson [this message]
     [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='20180608133014eucas1p1e9e52b0b4584862e5abeff6f51fab5d4~2MngR8fDf0722407224eucas1p1U@eucas1p1.samsung.com' \
    --to=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).