Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Non-greedy matching (S-flag) behaving weird
- X-seq: zsh-users 23447
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Non-greedy matching (S-flag) behaving weird
- Date: Fri, 8 Jun 2018 08:48:05 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=qrffAl/Mg5mMuOuErLFj23+nRC+59j6C9EPKr5wjlQA=; b=SqjeVNGweZU//IuCWuxcCHQIYqFA/2DtAyXj62XLAN1pFLSiFileLeypsDg59JPDrJ seDNpRb9TSB9GF/eDlwesXIFBpS1HQCZ/QHMWY1C7BmnxdkyPslcVMwaJmVUYhW/BXxM is45Ae7ybNdXO58m/cal1DiwBFE8meNnGZYb3KFAG9rytDtPVZee5y5BJyhYj3EbHc1B VV2IUmMxsc5KevIp41MsH3E3N8L+1DAyfiX9/dXrOfFQFdPxEjbbgOtRguBF++69QHGl VKYhD31AVRxRTKV1K+9yVgYmDqlI4I6x5hrxmegQgM0RqPb6DrTGFYgvluL/xvWMe/CV Y0xg==
- 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
Hello,
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"
--
Best regards,
Sebastian Gniazdowski
Messages sorted by:
Reverse Date,
Date,
Thread,
Author