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


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

Re: Swap lowercase and uppercase letters

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Swap lowercase and uppercase letters
Date 2013-03-19 05:51 +0000
Message-ID <ki8ucg$o46$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


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.

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web