Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: changing case to Title Case [redux]
- X-seq: zsh-users 26778
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: TJ Luoma <luomat@xxxxxxxxx>
- Cc: Zsh MailingList <zsh-users@xxxxxxx>
- Subject: Re: changing case to Title Case [redux]
- Date: Sat, 19 Jun 2021 00:06:35 -0700
- Archived-at: <https://zsh.org/users/26778>
- In-reply-to: <CADjGqHusQwz=W+Qht1pAd-wYqe5A1tArav=XSBZ=fNyq4o1SNA@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CADjGqHusQwz=W+Qht1pAd-wYqe5A1tArav=XSBZ=fNyq4o1SNA@mail.gmail.com>
On Fri, Jun 18, 2021 at 11:20 PM TJ Luoma <luomat@xxxxxxxxx> wrote:
>
> > print -r -- ${${(L)foo}//(#b)((#s)|[[:space:]])([[:alpha:]])/$match[1]${(U)match[2]}}
>
> That works great in Terminal.app on my Mac, but I can't get it to work in a shell script:
Use of (#b)(#s) and $match needs extendedglob, which isn't enabled for "zsh -f".
BTW, the for-loop isn't needed, this is a one-liner except for the setopt:
#!/usr/bin/env zsh -f
setopt extendedglob
print -r -- ${${(L)@}//(#b)((#s)|[[:space:]])([[:alpha:]])/$match[1]${(U)match[2]}}
In the current development version, you can enable extendedglob for a
single parameter substitution with the (*) flag:
#!/usr/bin/env zsh -f
print -r -- ${(*)${(L)@}//(#b)((#s)|[[:space:]])([[:alpha:]])/$match[1]${(U)match[2]}}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author