From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1472 invoked by alias); 16 Oct 2015 01:16:09 -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: X-Seq: 20763 Received: (qmail 21855 invoked from network); 16 Oct 2015 01:16:06 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Authority-Analysis: v=2.1 cv=T/C1EZ6Q c=1 sm=1 tr=0 a=vsFYQC4/11PqlKifmEOq9w==:117 a=vsFYQC4/11PqlKifmEOq9w==:17 a=N659UExz7-8A:10 a=tZgGgYnWvG9LqrA1wOUA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19 a=pILNOxqGKmIA:10 Message-id: <56204FD3.9040500@eastlink.ca> Date: Thu, 15 Oct 2015 18:16:03 -0700 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: backreferences References: <561FF039.9020202@eastlink.ca> <151015161602.ZM30622@torch.brasslantern.com> In-reply-to: <151015161602.ZM30622@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit On 10/15/2015 04:16 PM, Bart Schaefer wrote: > [[ "$sstring" = (#b)([^i]#inside)(*) ]] Very good, I tried a few things and missed the one that works. But I'm finding out that it's dangerous w.o. the test, since 'match' will remain silently unchanged if the comparison fails. > ... or it might mean that > you're trying to not-match multiple characters in the tested string in > a certain order. Yes. > In the latter case you want ^(string), or more often > (^(string)), but you also must setopt EXTENDED_GLOB. Sorry for the ambiguity. Clarity in the mind of the sender and clarity in the mind of the receiver are not the same thing. I mean that the match should fail not on meeting one character (or selection of characters), but it should fail on meeting a specific sequence of characters: test () { sstring="abcdeedcbaabcde" if [[ "$sstring" = (#b)([(^(edcba))]*)(edcba)(*) ]]; then echo "you have a match" else match= fi echo "one $match[1]" echo "two $match[2]" echo "three $match[3]" } one abcde two edcba three abcde I tried to learn how to do that with sed and never did get it figured out. zsh can give us just about most of what we want anyway. Pretty cool. Thanks.