Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > String Manipulation > StringLength >

StringLength

StringLength
gives the number of characters in a string.
  • StringLength counts special characters such as as single characters, even if their full names involve many characters.
Find the number of characters in a string:
Find the number of characters in a string:
In[1]:=
Click for copyable input
Out[1]=
Find lengths of all strings in a list:
StringLength treats special characters just like ordinary ones:
Newlines count as one character:
Find the growth rate of a string substitution system:
The empty string has zero length:
Formatting constructs are included in giving lengths of formatted strings:
StringLength counts every character as length 1, regardless of the length of its full name:
New in 1 | Last modified in 5.1
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF