({{, (RefLink[StringLength, paclet:ref/StringLength])["string"]
gives the number of characters in a string. }})

OpenersNotesSection(Spacer1)Details

(RefLink[StringLength, paclet:ref/StringLength]) counts special characters such as α as single characters, even if their full names involve many characters.

(RefLink[StringLength, paclet:ref/StringLength])[{(Subscript[s, 1]),(Subscript[s, 2]),…}] gives the list of lengths of each of the (Subscript[s, i]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (8)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Find the number of characters in a string:

StringLength["tiger"]

OpenersExampleSection1(Spacer1)Scope  (3)

Find lengths of all strings in a list:

StringLength[{"cat","dog","fish","coelenterate"}]

(RefLink[StringLength, paclet:ref/StringLength]) treats special characters just like ordinary ones:

StringLength["◆αβγ⟷𝒜ℬ𝒞↵"]

Newlines count as one character:

"ab\ncd"

StringLength[%]

OpenersExampleSection2(Spacer1)Applications  (1)

Find the growth rate of a string substitution system:

NestList[StringReplace[#,{"A"->"AB","B"->"A"}]&,"A",5]

StringLength[%]

OpenersExampleSection3(Spacer1)Properties & Relations  (1)

The empty string has zero length:

StringLength[""]

OpenersExampleSection4(Spacer1)Possible Issues  (2)

Formatting constructs are included in giving lengths of formatted strings:

FullForm["red"]

StringLength["red"]

(RefLink[StringLength, paclet:ref/StringLength]) counts every character as length 1, regardless of the length of its full name:

FullForm["αβγ"]

StringLength["αβγ"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Length, paclet:ref/Length])  ▪  (RefLink[Characters, paclet:ref/Characters])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Operations on Strings, paclet:tutorial/OperationsOnStrings])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[String Operations, paclet:guide/StringOperations])}, {▪(RefLinkPlain[String Manipulation, paclet:guide/StringManipulation])}, {▪(RefLinkPlain[Atomic Elements of Expressions, paclet:guide/AtomicElementsOfExpressions])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/11-strings-and-text.html])(WebLink[: Strings and Text, https://www.wolfram.com/language/elementary-introduction/11-strings-and-text.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-NKS.png(Spacer1)NKS|Online, http://www.wolframscience.com/nksonline/index/search.cgi?SearchIndex=StringLength]) ((WebLink[A New Kind of Science, http://www.wolframscience.com/nksonline/]))}})}})