From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4806 invoked by alias); 3 Mar 2016 09:41:48 -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: 21343 Received: (qmail 15781 invoked from network); 3 Mar 2016 09:41:47 -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 autolearn=ham autolearn_force=no version=3.4.1 X-AuditID: cbfec7f5-f79b16d000005389-ee-56d806d63433 Date: Thu, 03 Mar 2016 09:41:40 +0000 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: substitution groups and patterns i replace string (Emacs' \\1 etc.) Message-id: <20160303094140.705eb3bd@pwslap01u.europe.root.pri> In-reply-to: <87k2lk2ws9.fsf@debian.uxu> References: <87k2lk2ws9.fsf@debian.uxu> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHLMWRmVeSWpSXmKPExsVy+t/xq7rX2G6EGdz4aGCx4+RKRgdGj1UH PzAFMEZx2aSk5mSWpRbp2yVwZax/f4Op4BZLxfPbn1gbGK8xdzFycEgImEi8XlbTxcgJZIpJ XLi3nq2LkYtDSGApo8S3FcvYIZxpTBKPj5xghnBOM0q0/H3MCOGcYZRY/OwGO8goFgFVibfb y0BGsQkYSkzdNJsRxBYREJVYvmIzO4gtLBAgsW3KXTYQm1fAXmLBymtMIDangIbE6lu3WEHG CAmoS3y6mwcS5hfQl7j69xMTxHX2EjOvnGGEaBWU+DH5HguIzSygJbF5WxMrhC0vsXnNW2YQ G2TMjbu72ScwCs9C0jILScssJC0LGJlXMYqmliYXFCel5xrpFSfmFpfmpesl5+duYoSE8tcd jEuPWR1iFOBgVOLhvdFwPUyINbGsuDL3EKMEB7OSCO9m5hthQrwpiZVVqUX58UWlOanFhxil OViUxHln7nofIiSQnliSmp2aWpBaBJNl4uCUamCs4370pe5HtYjvqhX57PwRTc/mRgYZhl18 eEvz07Omssw/u/7IzrrH3p+wyYL3d5+9vc5i++eyj6sDeNdOW/1wweSV2xecOLJM9fwqqWc8 TUY6UrZbL0vtPGyZG3N8gewU1VD1wxlr1VbcMvStZFVdE2VpJsg7+546/5HXnd/Yoi2D82dt mXFViaU4I9FQi7moOBEAQFoV92ECAAA= On Thu, 3 Mar 2016 02:08:22 +0100 Emanuel Berg wrote: > When I do substitution, can I do groups and patterns > like in Emacs with \\1, \\2 to reference the > particular matches, and thus construct the replace > string out of them any way I like? You do it with $match, and if you need to refer to positions in the original string, $mbegin and $mend. See the description of the (#b) pattern in the zshexpn manual page. local -a match mbegin mend if [[ $url = (#b)http://(*) ]]; then print $match[1] fi Works with other forms of pattern matching. pws