From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15743 invoked by alias); 16 Oct 2015 04:27:05 -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: 20766 Received: (qmail 19986 invoked from network); 16 Oct 2015 04:27:04 -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,HTML_MESSAGE autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=eKU0VVhIW4hcwkN0JFscv5mL0eNuu3bCvrZZJ9bouGA=; b=ThFp05BomeoKtmibCEcscxbmw+4PKbo/g1pu0ox9g8mCLbd1OZkbD9q2cqrhMM1/FN XBwgKjDPMSwsJ/SJHp2sE4ggnI8EdrJhAwc5JRJEsLcdjHJOXmt7cLCl4dP9kaxPOsk4 LAxz2RQuBZHI/c+Rw4UXy4Xs2k4aAU62n/0da0DyzrP1vvpce5IASKxSVOEE36UBEA+b +VBff9TkFCBTCLA9hNtAYcZa9yL+lNIo2N+bikkzqMvslN5+h0wA6KexP2PAVa6PJacv 566SP6ifD+jyieNMzhd7OyjtqI8PwnAIV/db42QYPoal+fr9XiX1n55oZcIWGLJrEIu+ bHwg== X-Gm-Message-State: ALoCoQmLdyoIvxTTZOnniY8FgfAy+NWwNgcfPdGO9q+ZcAhBA/DK0r2pe1809cQP3TkrJrocU+mH MIME-Version: 1.0 X-Received: by 10.55.195.71 with SMTP id a68mr16995282qkj.15.1444969621703; Thu, 15 Oct 2015 21:27:01 -0700 (PDT) In-Reply-To: References: <561FF039.9020202@eastlink.ca> <151015161602.ZM30622@torch.brasslantern.com> <56204FD3.9040500@eastlink.ca> <151015193032.ZM30783@torch.brasslantern.com> Date: Thu, 15 Oct 2015 21:27:01 -0700 Message-ID: Subject: Re: backreferences From: Kurtis Rader To: Mikael Magnusson Cc: Bart Schaefer , Zsh Users Content-Type: multipart/alternative; boundary=001a113c9216036c410522313552 --001a113c9216036c410522313552 Content-Type: text/plain; charset=UTF-8 On Thu, Oct 15, 2015 at 9:11 PM, Mikael Magnusson wrote: > > As a sidenote, (^foo)* is always useless to write, since (^foo) will > expand to the empty string, and then the * will consume anything else. > A useful way to think of (^foo) is a * that will exclude any matches > that don't match the pattern foo. As a recovering Perl addict I cannot +1 this comment enough. Regular expressions are highly addictive and dangerous. But as Mikael points out it is extremely easy to write a regexp that is worse than worthless. Google "regular expression negative lookahead". Also, Google "now you have two problems". You'll find numerous articles talking about Jamie Zawinski's observation: "Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems." I wholeheartedly agree with that sentiment. Notwithstanding the fact I still employ regular expressions every single day. The important thing being that I avoid them outside of ad-hoc interactive searches unless I have expended considerable thought about their correctness and failure modes if handed malformed input. -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank --001a113c9216036c410522313552--