* How to capitalize last character of a string?
@ 2010-10-26 20:27 nix
2010-10-26 20:49 ` Eric De Mund
0 siblings, 1 reply; 7+ messages in thread
From: nix @ 2010-10-26 20:27 UTC (permalink / raw)
To: zsh-users
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to capitalize last character of a string?
2010-10-26 20:27 How to capitalize last character of a string? nix
@ 2010-10-26 20:49 ` Eric De Mund
2010-10-26 21:42 ` nix
0 siblings, 1 reply; 7+ messages in thread
From: Eric De Mund @ 2010-10-26 20:49 UTC (permalink / raw)
To: zsh-users; +Cc: nix
nix,
nix@myproxylists.com 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@ixian.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to capitalize last character of a string?
2010-10-26 20:49 ` Eric De Mund
@ 2010-10-26 21:42 ` nix
2010-10-26 21:56 ` Linus Arver
0 siblings, 1 reply; 7+ messages in thread
From: nix @ 2010-10-26 21:42 UTC (permalink / raw)
To: zsh-users
> nix,
>
> nix@myproxylists.com 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@ixian.com
>
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to capitalize last character of a string?
2010-10-26 21:42 ` nix
@ 2010-10-26 21:56 ` Linus Arver
0 siblings, 0 replies; 7+ messages in thread
From: Linus Arver @ 2010-10-26 21:56 UTC (permalink / raw)
To: nix; +Cc: zsh-users
On Tue, Oct 26, 2010 at 2:42 PM, <nix@myproxylists.com> wrote:
> 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
I'm pretty new to brace expansion myself, but by looking at your code
I figured it out:
TEST=word
print ${(C)TEST[1]}$TEST[2,-2]${(C)TEST[-1]}
output: WorD
-Linus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to capitalize last character of a string?
2010-10-26 11:56 ` András Nemes
@ 2010-10-26 13:08 ` Mikael Magnusson
0 siblings, 0 replies; 7+ messages in thread
From: Mikael Magnusson @ 2010-10-26 13:08 UTC (permalink / raw)
To: zsh-users
On 26 October 2010 13:56, András Nemes <andras.nemes@gmail.com> wrote:
> nearly there.
>
> print "$TEST[1,-2]${(C)TEST[-1]}"
>
> On Tue, Oct 26, 2010 at 10:42 PM, <nix@myproxylists.com> wrote:
>> 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.
And if for some reason you want to capitalize the last letter of every
word in a sentence (really, when don't you want to do that?),
% TEST="this is a sentence"
% echo ${(j::)${(@Oa)${(s::)${(Cj::)${(@Oa)${(s::)TEST}}}}}}
thiS iS A sentencE
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to capitalize last character of a string?
2010-10-26 11:42 nix
@ 2010-10-26 11:56 ` András Nemes
2010-10-26 13:08 ` Mikael Magnusson
0 siblings, 1 reply; 7+ messages in thread
From: András Nemes @ 2010-10-26 11:56 UTC (permalink / raw)
To: zsh-users
nearly there.
print "$TEST[1,-2]${(C)TEST[-1]}"
On Tue, Oct 26, 2010 at 10:42 PM, <nix@myproxylists.com> wrote:
> 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.
>
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* How to capitalize last character of a string?
@ 2010-10-26 11:42 nix
2010-10-26 11:56 ` András Nemes
0 siblings, 1 reply; 7+ messages in thread
From: nix @ 2010-10-26 11:42 UTC (permalink / raw)
To: zsh-users
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-10-26 21:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-26 20:27 How to capitalize last character of a string? nix
2010-10-26 20:49 ` Eric De Mund
2010-10-26 21:42 ` nix
2010-10-26 21:56 ` Linus Arver
-- strict thread matches above, loose matches on Subject: below --
2010-10-26 11:42 nix
2010-10-26 11:56 ` András Nemes
2010-10-26 13:08 ` Mikael Magnusson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).