Characters in Strings

Characters["string"]convert a string to a list of characters
StringJoin[{"c1","c2",...}]convert a list of characters to a string

Converting between strings and lists of characters.

This gives a list of the characters in the string.
In[1]:=
Click for copyable input
Out[1]=
You can apply standard list manipulation operations to this list.
In[2]:=
Click for copyable input
Out[2]=
StringJoin converts the list of characters back to a single string.
In[3]:=
Click for copyable input
Out[3]=
DigitQ[string]test whether all characters in a string are digits
LetterQ[string]test whether all characters in a string are letters
UpperCaseQ[string]test whether all characters in a string are uppercase letters
LowerCaseQ[string]test whether all characters in a string are lowercase letters

Testing characters in a string.

All characters in the string given are letters.
In[4]:=
Click for copyable input
Out[4]=
Not all the letters are uppercase, so the result is False.
In[5]:=
Click for copyable input
Out[5]=
ToUpperCase[string]generate a string in which all letters are uppercase
ToLowerCase[string]generate a string in which all letters are lowercase

Converting between upper case and lower case.

This converts all letters to upper case.
In[6]:=
Click for copyable input
Out[6]=
CharacterRange["c1","c2"]generate a list of all characters from and

Generating ranges of characters.

This generates a list of lowercase letters in alphabetical order.
In[7]:=
Click for copyable input
Out[7]=
Here is a list of uppercase letters.
In[8]:=
Click for copyable input
Out[8]=
Here are some digits.
In[9]:=
Click for copyable input
Out[9]=

CharacterRange will usually give meaningful results for any range of characters that have a natural ordering. The way CharacterRange works is by using the character codes that Mathematica internally assigns to every character.

This shows the ordering defined by the internal character codes used by Mathematica.
In[10]:=
Click for copyable input
Out[10]=
New to Mathematica? Find your learning path »
Have a question? Ask support »