* Title Case a Textified String
@ 2010-03-11 12:43 zzapper
2010-03-11 13:10 ` Mikael Magnusson
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: zzapper @ 2010-03-11 12:43 UTC (permalink / raw)
To: zsh-users
Hi
I want to convert a textified string to a Title Case Phrase
eg
fred-goat-dog.jpg to Fred Goat Dog
My first timid effort
echo "fred-goat-dog.jpg" | sed 's/-/ /g' | sed 's/\.jpg//'
Perl would do this with ease but is there a zsh solution (of course there
is!)
--
zzapper
http://zzapper.co.uk/ Technical Tips
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Title Case a Textified String
2010-03-11 12:43 Title Case a Textified String zzapper
@ 2010-03-11 13:10 ` Mikael Magnusson
2010-03-11 13:14 ` Frank Terbeck
2010-03-11 13:36 ` Radoulov, Dimitre
2 siblings, 0 replies; 9+ messages in thread
From: Mikael Magnusson @ 2010-03-11 13:10 UTC (permalink / raw)
To: zzapper; +Cc: zsh-users
On 11 March 2010 13:43, zzapper <david@tvis.co.uk> wrote:
> Hi
> I want to convert a textified string to a Title Case Phrase
>
> eg
> fred-goat-dog.jpg to Fred Goat Dog
>
> My first timid effort
>
> echo "fred-goat-dog.jpg" | sed 's/-/ /g' | sed 's/\.jpg//'
>
>
> Perl would do this with ease but is there a zsh solution (of course there
> is!)
foo=fred-goat-dog.jpg
echo ${(C)foo:gs/-/ /:r}
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Title Case a Textified String
2010-03-11 12:43 Title Case a Textified String zzapper
2010-03-11 13:10 ` Mikael Magnusson
@ 2010-03-11 13:14 ` Frank Terbeck
2010-03-11 13:36 ` Radoulov, Dimitre
2 siblings, 0 replies; 9+ messages in thread
From: Frank Terbeck @ 2010-03-11 13:14 UTC (permalink / raw)
To: zzapper; +Cc: zsh-users
zzapper wrote:
> I want to convert a textified string to a Title Case Phrase
>
> eg
> fred-goat-dog.jpg to Fred Goat Dog
>
> My first timid effort
>
> echo "fred-goat-dog.jpg" | sed 's/-/ /g' | sed 's/\.jpg//'
>
>
> Perl would do this with ease but is there a zsh solution (of course there
> is!)
Yeah, there is:
% foo='fred-goat-dog.jpg'
% print ${(C)${foo:r}//-/ }
Fred Goat Dog
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Title Case a Textified String
2010-03-11 12:43 Title Case a Textified String zzapper
2010-03-11 13:10 ` Mikael Magnusson
2010-03-11 13:14 ` Frank Terbeck
@ 2010-03-11 13:36 ` Radoulov, Dimitre
2010-03-11 13:45 ` Mikael Magnusson
2 siblings, 1 reply; 9+ messages in thread
From: Radoulov, Dimitre @ 2010-03-11 13:36 UTC (permalink / raw)
To: zzapper; +Cc: zsh-users
On 11/03/2010 13.43, zzapper wrote:
> Hi
> I want to convert a textified string to a Title Case Phrase
>
> eg
> fred-goat-dog.jpg to Fred Goat Dog
>
% print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
Fred Goat Dog
Regards
Dimitre
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Title Case a Textified String
2010-03-11 13:36 ` Radoulov, Dimitre
@ 2010-03-11 13:45 ` Mikael Magnusson
2010-03-11 13:50 ` Radoulov, Dimitre
0 siblings, 1 reply; 9+ messages in thread
From: Mikael Magnusson @ 2010-03-11 13:45 UTC (permalink / raw)
To: Radoulov, Dimitre; +Cc: zzapper, zsh-users
On 11 March 2010 14:36, Radoulov, Dimitre <cichomitiko@gmail.com> wrote:
> On 11/03/2010 13.43, zzapper wrote:
>>
>> Hi
>> I want to convert a textified string to a Title Case Phrase
>>
>> eg
>> fred-goat-dog.jpg to Fred Goat Dog
>>
>
> % print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
> Fred Goat Dog
Okay, yours has the most smileys, so I guess you win this round.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Title Case a Textified String
2010-03-11 13:45 ` Mikael Magnusson
@ 2010-03-11 13:50 ` Radoulov, Dimitre
2010-03-11 13:58 ` Radoulov, Dimitre
0 siblings, 1 reply; 9+ messages in thread
From: Radoulov, Dimitre @ 2010-03-11 13:50 UTC (permalink / raw)
To: Mikael Magnusson; +Cc: zzapper, zsh-users
On 11/03/2010 14.45, Mikael Magnusson wrote:
> On 11 March 2010 14:36, Radoulov, Dimitre<cichomitiko@gmail.com> wrote:
>
>> On 11/03/2010 13.43, zzapper wrote:
>>
>>> Hi
>>> I want to convert a textified string to a Title Case Phrase
>>>
>>> eg
>>> fred-goat-dog.jpg to Fred Goat Dog
>>>
>>>
>> % print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
>> Fred Goat Dog
>>
> Okay, yours has the most smileys, so I guess you win this round.
>
When I read yours, I though it would have been better to wait (not to
post) :)
I prefer your version (both r and // seem cleaner to me).
Regards
Dimitre
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Title Case a Textified String
2010-03-11 13:50 ` Radoulov, Dimitre
@ 2010-03-11 13:58 ` Radoulov, Dimitre
2010-03-11 17:23 ` zzapper
0 siblings, 1 reply; 9+ messages in thread
From: Radoulov, Dimitre @ 2010-03-11 13:58 UTC (permalink / raw)
To: Mikael Magnusson; +Cc: zzapper, zsh-users
On 11/03/2010 14.50, Radoulov, Dimitre wrote:
> On 11/03/2010 14.45, Mikael Magnusson wrote:
>> On 11 March 2010 14:36, Radoulov, Dimitre<cichomitiko@gmail.com> wrote:
>>> On 11/03/2010 13.43, zzapper wrote:
>>>> Hi
>>>> I want to convert a textified string to a Title Case Phrase
>>>>
>>>> eg
>>>> fred-goat-dog.jpg to Fred Goat Dog
>>>>
>>> % print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
>>> Fred Goat Dog
>> Okay, yours has the most smileys, so I guess you win this round.
>
> When I read yours, I though it would have been better to wait (not to
> post) :)
> I prefer your version (both r and // seem cleaner to me).
> ^^^
I mean :gs, not //.
Dimitre
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Title Case a Textified String
2010-03-11 13:58 ` Radoulov, Dimitre
@ 2010-03-11 17:23 ` zzapper
2010-03-12 11:01 ` Radoulov, Dimitre
0 siblings, 1 reply; 9+ messages in thread
From: zzapper @ 2010-03-11 17:23 UTC (permalink / raw)
To: zsh-users
>>>>> I want to convert a textified string to a Title Case Phrase
>>>>>
>>>>> eg
>>>>> fred-goat-dog.jpg to Fred Goat Dog
>>>>>
>>>> % print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
>>>> Fred Goat Dog
>>> Okay, yours has the most smileys, so I guess you win this round.
Thanks both of you and for completeness (and for anyone googling into this
thread)
a solution to textify Fred Goat Dog to fred-goat-dog.jpg?
--
zzapper
http://zzapper.co.uk/ Technical Tips
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Title Case a Textified String
2010-03-11 17:23 ` zzapper
@ 2010-03-12 11:01 ` Radoulov, Dimitre
0 siblings, 0 replies; 9+ messages in thread
From: Radoulov, Dimitre @ 2010-03-12 11:01 UTC (permalink / raw)
To: zzapper; +Cc: zsh-users
On 11/03/2010 18.23, zzapper wrote:
>>>>>> I want to convert a textified string to a Title Case Phrase
>>>>>>
>>>>>> eg
>>>>>> fred-goat-dog.jpg to Fred Goat Dog
>>>>>>
>>>>>>
>>>>> % print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
>>>>> Fred Goat Dog
>>>>>
>>>> Okay, yours has the most smileys, so I guess you win this round.
>>>>
> Thanks both of you and for completeness (and for anyone googling into this
> thread)
> a solution to textify Fred Goat Dog to fred-goat-dog.jpg?
>
>
% s='Fred Goat Dog'
% print ${(L)s:gs/ /-/}.jpg
fred-goat-dog.jpg
Or:
% print ${(L)s// /-}.jpg
fred-goat-dog.jpg
Regards
Dimitre
Regards
Dimitre
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-03-12 11:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-11 12:43 Title Case a Textified String zzapper
2010-03-11 13:10 ` Mikael Magnusson
2010-03-11 13:14 ` Frank Terbeck
2010-03-11 13:36 ` Radoulov, Dimitre
2010-03-11 13:45 ` Mikael Magnusson
2010-03-11 13:50 ` Radoulov, Dimitre
2010-03-11 13:58 ` Radoulov, Dimitre
2010-03-11 17:23 ` zzapper
2010-03-12 11:01 ` Radoulov, Dimitre
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).