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 09:15:34 +0100	[thread overview]
Message-ID: <20180608081535eucas1p1cf8eab9e4500aaf73521e32a19df0bf5~2IUxfX6MX1459414594eucas1p15@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]}}";
> 
> ~ 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


  reply	other threads:[~2018-06-08  8:23 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 [this message]
2018-06-08 12:42     ` Sebastian Gniazdowski
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='20180608081535eucas1p1cf8eab9e4500aaf73521e32a19df0bf5~2IUxfX6MX1459414594eucas1p15@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).