Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Swap lowercase and uppercase letters
Replies: 5   Last Post: Mar 20, 2013 4:22 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alexei Boulbitch

Posts: 479
Registered: 2/28/08
Re: Swap lowercase and uppercase letters
Posted: Mar 20, 2013 4:22 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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







Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.