From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15818 invoked by alias); 25 Feb 2015 21:24:56 -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: 19925 Received: (qmail 20935 invoked from network); 25 Feb 2015 21:24:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Wed, 25 Feb 2015 22:18:56 +0100 From: Roman Neuhauser To: Kartik Agaram Cc: zsh-users@zsh.org Subject: Re: parameter expansion with '$' Message-ID: <20150225211856.GD4524@isis.sigpipe.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) # ak@akkartik.com / 2015-02-25 12:50:16 -0800: > I'd like to only perform the substitution when 'c' occurs at the > end of the string: > > $ echo ${X/c$/} > abc # I'd like this to return 'ab' like above > > I assume others see the same results? Can anybody help me understand why it > doesn't work, and how I can interpret the '$' as a regular expression > wildcard rather than some other sort of zsh sigil? these patterns are *not* regular expressions. zshexpn(1) says near the start of PARAMETER EXPANSION: In the expansions discussed below that require a pattern, the form of the pattern is the same as that used for filename generation; see the section `Filename Generation'. ${name/pattern/repl} ${name//pattern/repl} [...] The pattern may begin with a `#', in which case the pattern must match at the start of the string, or `%', in which case it must match at the end of the string, or `#%' in which case the pat- tern must match the entire string. [...] Note also that the `#', `%' and `#%' are not active if they occur inside a substituted parameter, even at the start. -- roman