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


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

Re: Swap lowercase and uppercase letters

From Szabolcs <szhorvat@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Swap lowercase and uppercase letters
Date 2013-03-19 04:04 +0000
Message-ID <ki8o4n$ko6$1@smc.vnet.net> (permalink)
References <ki6n3l$gee$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


On Monday, 18 March 2013 05:34:45 UTC-4, 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!"
> 


This is a reliable method that will work with scripts other than Roman (such as Greek or Cyrillic) and will also work with many accented letter:

StringJoin@
 Replace[Characters["hELLO THERE!"], {c_?LowerCaseQ :> ToUpperCase[c],
    c_?UpperCaseQ :> ToLowerCase[c]}, {1}]

Simply replacing A, B, ..., Z with a, b, ..., z is not a good option because it won't handle accented letters (unless you include those as well, which is a lot of work)

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


Thread

Swap lowercase and uppercase letters Bill <WDWNORWALK@aol.com> - 2013-03-18 09:34 +0000
  Re: Swap lowercase and uppercase letters Szabolcs <szhorvat@gmail.com> - 2013-03-19 04:04 +0000
    Re: Swap lowercase and uppercase letters awnl <awnl@gmx-topmail.de> - 2013-03-20 08:22 +0000

csiph-web