From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28942 invoked from network); 10 Aug 2004 11:52:56 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Aug 2004 11:52:56 -0000 Received: (qmail 92115 invoked from network); 10 Aug 2004 11:52:50 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Aug 2004 11:52:50 -0000 Received: (qmail 15763 invoked by alias); 10 Aug 2004 11:52:08 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7816 Received: (qmail 15753 invoked from network); 10 Aug 2004 11:52:07 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 10 Aug 2004 11:52:07 -0000 Received: (qmail 90629 invoked from network); 10 Aug 2004 11:50:09 -0000 Received: from madrid10.amenworld.com (62.193.203.32) by a.mx.sunsite.dk with SMTP; 10 Aug 2004 11:50:06 -0000 Received: from DervishD.pleyades.net (212.Red-80-35-44.pooles.rima-tde.net [80.35.44.212]) by madrid10.amenworld.com (8.10.2/8.10.2) with ESMTP id i7ABo1A13282 for ; Tue, 10 Aug 2004 13:50:02 +0200 Received: from raul@pleyades.net by DervishD.pleyades.net with local (Exim MTA 2.05) id <1BuVAA-0000UF-00>; Tue, 10 Aug 2004 13:51:30 +0200 Date: Tue, 10 Aug 2004 13:51:30 +0200 From: DervishD To: Zsh Users Subject: Re: Getting a particular char Message-ID: <20040810115130.GD1825@DervishD> Mail-Followup-To: Zsh Users References: <20040806105541.GE24158@DervishD> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20040806105541.GE24158@DervishD> User-Agent: Mutt/1.4.2.1i Organization: Pleyades X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 Hi all :) * DervishD dixit: > If I want to get the character number 'n' from a parameter [...] > So I change it to something like 'expr substr $parameter n 1'. > This has some problems, like '$parameter' needing some tweaking so > 'expr' doesn't whine because it starts with '(', '+', etc. or it is > something like the word 'match'. But all that is not important, > because the 'substr' expression is not SUSv3 compliant, so I cannot > do that neither. Finally I did this way (thanks to Paul Eggert, coauthor of GNU coreutils, for the help): expr "x$parameter" : ".\{n\}\(.\)" Where 'n' is the index of the character we want. Easy and fully SUSv3 compliant, where {N} is a valid BRE for repetition. Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 http://www.pleyades.net & http://raul.pleyades.net/