Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13897 > unrolled thread

Re: Swap lowercase and uppercase letters

Started byBill Rowe <readnews@sbcglobal.net>
First post2013-03-19 05:51 +0000
Last post2013-03-19 05:51 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Swap lowercase and uppercase letters Bill Rowe <readnews@sbcglobal.net> - 2013-03-19 05:51 +0000

#13897 — Re: Swap lowercase and uppercase letters

FromBill Rowe <readnews@sbcglobal.net>
Date2013-03-19 05:51 +0000
SubjectRe: Swap lowercase and uppercase letters
Message-ID<ki8ucg$o46$1@smc.vnet.net>
On 3/18/13 at 5:35 AM, WDWNORWALK@aol.com (Bill) wrote:

>Hi:

>I have the following example:  "hELLO THERE!"

>Using Mathematica 8.0.4, how can I swap the lowercase and uppercase
>letters to output,

>"Hello there!"

Although this isn't truly a swap of lowercase and uppercase, the
result is what you are asking for

In[2]:= ToUpperCase[StringTake[#, 1]] <>
    ToLowerCase[StringDrop[#, 1]] &["hELLO THERE!"]

Out[2]= Hello there!

If you want to do a litteral swamp of lower case and upper case
you could first convert the string to character codes then add
32 if the character code was between 65 ("A") and 90 ("Z") or
subtract 32 if the character code was between 97 ("a") and 122
("z") the use FromCharacter code and StringJoin to re-assemble
the string.

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web