* changing case to Title Case
@ 2012-05-14 19:30 TJ Luoma
2012-05-14 19:54 ` Valodim Skywalker
2012-05-15 19:29 ` Peter Stephenson
0 siblings, 2 replies; 3+ messages in thread
From: TJ Luoma @ 2012-05-14 19:30 UTC (permalink / raw)
To: zsh-users
$ foo="ONE TWO thRee FoUR"
$ print -r -- "${(C)foo}"
will output this:
One Two Three Four
but this:
$ foo="ONE TWO thRee FoUR's"
$ print -r -- "${(C)foo}"
will give this:
One Two Three Four'S
Note the S is capitalized
$ foo="ONE TWO thRee FoUR's.pdf"
$ print -r -- "${(C)foo}"
will give this:
One Two Three Four'S.Pdf
Note that the P in PDF and the S after ' are capitalized.
Is there any way to avoid that?
TjL
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: changing case to Title Case
2012-05-14 19:30 changing case to Title Case TJ Luoma
@ 2012-05-14 19:54 ` Valodim Skywalker
2012-05-15 19:29 ` Peter Stephenson
1 sibling, 0 replies; 3+ messages in thread
From: Valodim Skywalker @ 2012-05-14 19:54 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 241 bytes --]
I usually split off the extension for this, like:
${(C)foo:r}.${foo:e}
Note this might mess up for cases where $foo does not have an extension.
The 's is quite a special case, I don't think there's a non-ugly way to
handle it...
- V
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: changing case to Title Case
2012-05-14 19:30 changing case to Title Case TJ Luoma
2012-05-14 19:54 ` Valodim Skywalker
@ 2012-05-15 19:29 ` Peter Stephenson
1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2012-05-15 19:29 UTC (permalink / raw)
To: zsh-users
On Mon, 14 May 2012 15:30:49 -0400
TJ Luoma <luomat@gmail.com> wrote:
> $ foo="ONE TWO thRee FoUR"
> $ print -r -- "${(C)foo}"
>
> will output this:
>
> One Two Three Four
>
> but this:
>
> $ foo="ONE TWO thRee FoUR's"
> $ print -r -- "${(C)foo}"
>
>
>
> will give this:
>
> One Two Three Four'S
>
> Note the S is capitalized
If you like squiggles, you could do this:
print -r -- ${${(L)foo}//(#b)((#s)|[[:space:]])([[:alpha:]])/$match[1]${(U)match[2]}}
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-15 19:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-14 19:30 changing case to Title Case TJ Luoma
2012-05-14 19:54 ` Valodim Skywalker
2012-05-15 19:29 ` Peter Stephenson
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).