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


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

Re: Swap lowercase and uppercase letters

From Alexei Boulbitch <Alexei.Boulbitch@iee.lu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Swap lowercase and uppercase letters
Date 2013-03-20 08:22 +0000
Message-ID <kibrk8$14s$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


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!"


Thanks,

Bill

Hi, Bill,

These two functions:

revertCharacter[x_String] :=
  If[UpperCaseQ[x], ToLowerCase[x], ToUpperCase[x]];

revertString[string_String]:=Map[revertCharacter,Characters[string]]//StringJoin;

do the job in Mathematica 9 at least:

revertString@"hELLO THERE!"
revertString@"Hello there!"

"Hello there!"

"hELLO THERE!"

I expect that it should also work in the version 8.


Have fun, Alexei


Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu



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


Thread

Re: Swap lowercase and uppercase letters Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2013-03-20 08:22 +0000

csiph-web