Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert uppercase letters to lowercase and vice versa
ResourceFunction["SwapCase"][string] converts uppercase letters in string to lowercase and vice versa. |
Swap the cases in a string:
In[1]:= |
Out[1]= |
SwapCase automatically threads over a list of strings:
In[2]:= |
Out[2]= |
SwapCase can be programmed by using LowerCaseQ or UppercaseQ and the functions ToUpperCase and ToLowerCase:
In[3]:= |
Out[4]= |
The implementation of SwapCase is many times faster, though:
In[5]:= |
Out[6]= |
For nearly all strings, SwapCase is an involutory function:
In[7]:= |
Out[8]= |
There are a few exceptions:
In[9]:= |
Out[10]= |
Some strings will get longer after swapping cases:
In[11]:= |
Out[11]= |
This work is licensed under a Creative Commons Attribution 4.0 International License