From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31825 invoked from network); 28 Jun 2021 05:37:32 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Jun 2021 05:37:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Subject:Cc:To:From:Date: References:In-Reply-To:Message-Id:Mime-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=r0zdNAkZnmvZSWLXJ5VEDo9ePKUQmKv4lceX/XebEjo=; b=u5Zcytu2PI+96M0fKJ6T9pGNk6 0MVDR5ukZTym0JFu7vPzUbuEfPNoPQNnlOePZq8aR9F3UIOM+fR1vbeWK2DQsQVQfodGiV+PgQQUF mgZUh1bBIKICxPimiMdxGttamjFdPhQ8HJ+thqB4gWnsH1aiiYiV+T2+x2Ejlgf/P7NdwexhdqViu Si9x6iftjkP08DBa8hPC4vp6rKW8KUe7O0SBaxrzuBg6tvmChj3xUmEEG0qhZfsTLZj5AJ8qr1FWG vYH7sd6JHNHkNKFAmFZWeMltTaRQjk6MCTOvC6dGO8QBIt+hRs7wSH28dhWBZ/2KsNCU2J5GMtLW8 6J45WTUw==; Received: from authenticated user by zero.zsh.org with local id 1lxjxY-0009CE-QB; Mon, 28 Jun 2021 05:37:29 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lxjwt-0008Vk-Jk; Mon, 28 Jun 2021 05:36:48 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 56D0E27C0054; Mon, 28 Jun 2021 01:36:45 -0400 (EDT) Received: from imap2 ([10.202.2.52]) by compute3.internal (MEProxy); Mon, 28 Jun 2021 01:36:45 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeehfedgleefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreerjeenucfhrhhomhepnfgrfihr vghntggvpgggvghljoiiqhhuvgiiuceolhgrrhhrhihvseiishhhrdhorhhgqeenucggtf frrghtthgvrhhnpeehgfelledufeelheethffhieekkedvtdeuhfdtgffhiefhtedvjeet veehieduleenucffohhmrghinhepshhouhhrtggvfhhorhhgvgdrihhonecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhihvodhmvghs mhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudehudekjeejtdegqdduudelvdejfe ekhedqlhgrrhhrhihvpeepiihshhdrohhrghesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 061E6A0003D; Mon, 28 Jun 2021 01:36:45 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-530-gd0c265785f-fm-20210616.002-gd0c26578 Mime-Version: 1.0 Message-Id: <3da942af-a0ab-4413-848e-e71c537d4919@www.fastmail.com> In-Reply-To: References: <0CCFA5D7-9723-481E-9E20-D96E7F28D717@covisp.net> Date: Mon, 28 Jun 2021 01:34:24 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: Gamma , "Lewis Butler" Cc: zsh-users@zsh.org Subject: Re: Paramater subsiution Content-Type: text/plain X-Seq: 26783 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Sun, Jun 27, 2021, at 6:47 PM, Gamma wrote: > echo ${i##* - } > > Removes the longest prefix ending with ' - '. ${i#* - } would also work and would permit "name" to be completely arbitrary (assuming that "file 1234" could not possibly contain " - " as a substring). https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion On Sun, Jun 27, 2021, at 6:40 PM, Lewis Butler wrote: > I've trued using > > ${i:s/file \[0-9\]+ - //} > ${i:s/file \[0-9\]\[0-9\]\[0-9\]\[0-9\] - //} > ${i:s/file [0-9]+ - //} > ${i:s/file [0-9][0-9][0-9][0-9] - //} > ${i:s/file [^ ]+ - //} First, you probably wanted ${i/foo/bar} rather than ${i:s/foo/bar}. The latter matches foo literally unless the HIST_SUBST_PATTERN option is set. It's also less appropriate in a conceptual sense. Second, these substitution features use patterns ("globs"), not regular expressions. Bracket expressions are treated specially ([...], not \[...\]), but '+' generally is not. You can find details here, including how you could achieve the same effect as '+' (if you really must): https://zsh.sourceforge.io/Doc/Release/Expansion.html#Filename-Generation But you should use Gamma's solution (or my variant), which is simple and highly portable. -- vq