From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16725 invoked by alias); 27 Oct 2015 11:15:14 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36981 Received: (qmail 11098 invoked from network); 27 Oct 2015 11:15:13 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_NUMERIC_HELO,SPF_HELO_PASS, T_FSL_HELO_BARE_IP_2 autolearn=no autolearn_force=no version=3.4.0 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@zsh.org From: Stephane Chazelas Subject: Re: Issue with ${var#(*_)(#cN,M)} Date: Tue, 27 Oct 2015 11:11:38 +0000 Message-ID: <20151027111138.GB8170@chaz.gmail.com> References: <20151019093316.GA6957@chaz.gmail.com> <151019121728.ZM324@torch.brasslantern.com> <20151020190946.GA6560@chaz.gmail.com> <151020160422.ZM1778@torch.brasslantern.com> <20151027100034.45f487f0@pwslap01u.europe.root.pri> <20151027104633.2479414f@pwslap01u.europe.root.pri> <20151027110353.GA8170@chaz.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 2.222.9.138 Content-Disposition: inline In-Reply-To: <20151027110353.GA8170@chaz.gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) 2015-10-27 11:03:53 +0000, Stephane Chazelas: [...] > ksh93 is also fine with it: > > $ a='1_2_3_4_5' ksh -c 'echo "${a#{2}(*_)}"' > 3_4_5 > $ a='1_2_3_4_5' ksh -c 'echo "${a##{2}(*_)}"' > 5 > > The zsh limitation should probably be documented if not fixed. [...] Another work around is to use zsh's PCREs: $ a='1_2_3_4_5' zsh -o rematchpcre -c '[[ $a =~ "(?s)^(.*?_){2}" ]] &&echo $MATCH' 1_2_ $ a=$'1_2_3_4_5\nqweq' zsh -o rematchpcre -c '[[ $a =~ "(?s)^(?:.*?_){2}(.*)" ]]; echo $match' 3_4_5 qweq -- Stephane