MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Swap lowercase and uppercase letters

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130204] Re: Swap lowercase and uppercase letters
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Tue, 19 Mar 2013 01:51:31 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

On 3/18/13 at 5:35 AM, WDWNORWALK at 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.




  • Prev by Date: Re: OpenCL yes, Cuda no
  • Next by Date: Re: Multiple independent random number streams cannot be implemented.
  • Previous by thread: Re: Swap lowercase and uppercase letters
  • Next by thread: Re: Swap lowercase and uppercase letters