Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: no wildcards/anchors allowed in pattern? ${f:s/pattern/_s&}
- X-seq: zsh-users 28051
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-user <zsh-users@xxxxxxx>
- Subject: Re: no wildcards/anchors allowed in pattern? ${f:s/pattern/_s&}
- Date: Thu, 8 Sep 2022 14:16:43 +0100 (BST)
- Archived-at: <https://zsh.org/users/28051>
- Importance: Normal
- In-reply-to: <826663136.300323.1662640732618@mail.virginmedia.com>
- List-id: <zsh-users.zsh.org>
- References: <c7008a2b-9403-eed4-3f55-5e7f0debeb55@rayninfo.co.uk> <826663136.300323.1662640732618@mail.virginmedia.com>
Sorry, didn't go to the list, agian...
> On 08/09/2022 12:56 zzapper <zsh@xxxxxxxxxxxxxx> wrote:
> This works for me and allows me to use memory '&' but I'm frustrated
> that I don't seem to be able to use anchors / wildcards etc in the pattern
>
> f=dog.png ;echo $f '->' ${f:s/./_s&}
> dog.png -> dog_s.png
>
> the alternative syntax allows pattern to be a regexp but has no regexp
> memory
>
>
> f=dog.png.png ;echo $f '->' ${f/%.png/_s.png}
> dog.png.png -> dog.png_s.png
The pattern expansion case has this syntax:
f=stuff.png
print ${foo/%(#m).png/_$MATCH}
stuff_.png
Look up the "m" globbing flag.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author