From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2598 invoked by alias); 27 Oct 2015 11:05:18 -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: 36979 Received: (qmail 23039 invoked from network); 27 Oct 2015 11:05:18 -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:03:53 +0000 Message-ID: <20151027110353.GA8170@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> 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: <20151027104633.2479414f@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.21 (2010-09-15) 2015-10-27 10:46:33 +0000, Peter Stephenson: [...] > % egrep '^(*_){2}$' <<<'1_2_' > > fails to match completely, i.e the backtracking is too complicated > to handle, whereas [...] Except that it should be .* in REs and that REs are greedy. $ egrep '^(.*_){2}$' <<<'1_2_' 1_2_ $ grep -Eo '^(.*_){2}' <<<'1_2_3_4_5' 1_2_3_4_ $ grep -Po '^(.*?_){2}' <<<'1_2_3_4_5' 1_2_ 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. -- Stephane