Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13881 > unrolled thread
| Started by | Bill <WDWNORWALK@aol.com> |
|---|---|
| First post | 2013-03-18 09:34 +0000 |
| Last post | 2013-03-20 08:22 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | Bill <WDWNORWALK@aol.com> |
|---|---|
| Date | 2013-03-18 09:34 +0000 |
| Subject | Swap lowercase and uppercase letters |
| Message-ID | <ki6n3l$gee$1@smc.vnet.net> |
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
[toc] | [next] | [standalone]
| From | Szabolcs <szhorvat@gmail.com> |
|---|---|
| Date | 2013-03-19 04:04 +0000 |
| Message-ID | <ki8o4n$ko6$1@smc.vnet.net> |
| In reply to | #13881 |
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)
[toc] | [prev] | [next] | [standalone]
| From | awnl <awnl@gmx-topmail.de> |
|---|---|
| Date | 2013-03-20 08:22 +0000 |
| Message-ID | <kibrke$14v$1@smc.vnet.net> |
| In reply to | #13885 |
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)
>
or, slightly simpler:
StringReplace["hELLO THERE!", {
c_?UpperCaseQ :> ToLowerCase[c],
c_?LowerCaseQ :> ToUpperCase[c]
}]
regards,
albert
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web