Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to capitalize last character of a string?



> 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