Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to capitalize last character of a string?
- X-seq: zsh-users 15499
- From: nix@xxxxxxxxxxxxxxxx
- To: zsh-users@xxxxxxx
- Subject: Re: How to capitalize last character of a string?
- Date: Wed, 27 Oct 2010 00:42:53 +0300
- Importance: Normal
- In-reply-to: <19655.16111.999209.381824@xxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <a695c10a88b7d75ca26ac49f3bd7c5c6.squirrel@xxxxxxxxxxxxx> <19655.16111.999209.381824@xxxxxxxxx>
> nix,
>
> nix@xxxxxxxxxxxxxxxx writes:
> ] Subject: How to capitalize last character of a string?
> ] Hi, as the subject says, any guidance?
> ]
> ] TEST="word"
> ]
> ] print "${(C)TEST[1]}$TEST[2,-1]"
> ]
> ] Capitalizes the first character but somehow I could not come up with
> ] solution other way.
>
> I'm not familiar with the syntax, but inferred the following. It seems
> to work:
>
> % TEST="word"
> % print "$TEST[1,-2]${(C)TEST[-1]}"
> worD
> %
>
> Regards,
> Eric
> --
> Eric De Mund
> ead@xxxxxxxxx
>
Thanks. Sorry for duplicate question (i sent earlier this same question
and some other gave a solution). It works yes.
I am really having trouble with these modifiers. Last question: How to
apply both macros (Capitalize the first and the last letter) ?
[CapitaL]
So the result would be: WorD
Messages sorted by:
Reverse Date,
Date,
Thread,
Author