From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9363 invoked by alias); 8 Jun 2018 12:42:59 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23449 Received: (qmail 19028 invoked by uid 1010); 8 Jun 2018 12:42:59 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi0-f49.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.218.49):SA:0(-1.9/5.0):. Processed in 1.131556 secs); 08 Jun 2018 12:42:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=8CTONhPlPA98H0ov0LctLqSg0ipD5yb0BdcYHWiUsfc=; b=r8mc2qdglZlg0U7KaJb9OAX8WiSNc1/eEyx3zoynBqepdjmuiaeGjs5WGqFDe9QMlN An4kowLCD6E/N4nwcdAYq9evqKcWvn0Bpg9i2N8oMfNViiH8ztx7vJEqU3vsHdNDhaaB IhvbPDAxGLCbmn1XmhkBd98X8Ony9QRl4HbYhePajshUbQwLjpFjVipfprwu5loGQfSz RtvhUlxNJkOW7kRE7M14CyL0ys75k1rk8rCRsannyuu2b2Jh3YUoA5+vUNRUivlnfxIE JdznZDDeqfO+YSTHO8M/QOI23qJf6/H8Z301m/m51mZ/01nyDg+8rbfCkFdpNzmpqssQ WsrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8CTONhPlPA98H0ov0LctLqSg0ipD5yb0BdcYHWiUsfc=; b=cBJRyjnYTmn2jRsTpkYTElcbdYr3tIR43MIHY4PeMw2yJ8FnOU3upO+qB5M7SjpTFm ueaasdoTrwPs8fWRf0/Pp68Z3FlldYdnd8HCqUq+e51oubm9xwWzg9J+4lNRbX7BV7wd /MlpvBsXrQKhg1ctDPn7ABIC2vV8otBMRlGTYusqdIaRvYKEVOerTDwEQw+w+XsqNewl kyqrrbInKnTqlYTDoh9G+zvtmmPKmtYGsvhXEVQUFPLQYhBC4cCZ9CkDmMIc84+E00nt GDIuzgYmZsbBtePhPaRYPftyVytGavW2I9POTQXwkluboLMxhVv3UIGk10Gww/2Bwixc tF+w== X-Gm-Message-State: APt69E0M1S0ypEE89ymVBQ03+CCe6tLSdTEpqm3/p+ZatuJUn+dO1EE3 9pJm1Nokia+GOHQarjSTlHVFA1lybjVc7Hiz/dAXjA== X-Google-Smtp-Source: ADUXVKJZa34syhS5XvEi4rztdV5Jt3H0zHBXJXD25IZbMrFallS6hLaCOFD6msQhuBC21SuVDIrNMmNXXjuo46DzlNE= X-Received: by 2002:aca:c287:: with SMTP id s129-v6mr2399142oif.3.1528461775262; Fri, 08 Jun 2018 05:42:55 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20180608081535eucas1p1cf8eab9e4500aaf73521e32a19df0bf5~2IUxfX6MX1459414594eucas1p15@eucas1p1.samsung.com> References: <20180608081535eucas1p1cf8eab9e4500aaf73521e32a19df0bf5~2IUxfX6MX1459414594eucas1p15@eucas1p1.samsung.com> From: Sebastian Gniazdowski Date: Fri, 8 Jun 2018 14:42:34 +0200 Message-ID: Subject: Re: Non-greedy matching (S-flag) behaving weird To: Peter Stephenson Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" On 8 June 2018 at 10:15, Peter Stephenson wrote: > 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. You are apparently right, but it is a big surprise to me. * matching over what (a|b) should match, on string xxxaxxxb?? Well, this test works like I would expect: ~ buf='xxxaxxxbxxx'; print "${(S)buf/(#b)(*)(a|b)(*)/R}" Rxxxbxxx With greedy search (no (S)-flag): ~ buf='xxxaxxxbxxx'; print "${buf/(#b)(*)(a|b)(*)/R}" R However, I also tested vim, entering text: abcd BEGIN efgh END ijkl And then running matching with regex: .\{-}\(BEGIN\|END\).\{-} \{-} is non-greedy match. YET, this matched till END, not till BEGIN. Very weird. -- Best regards, Sebastian Gniazdowski