WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

StringLength ["string"]

gives the number of characters in a string.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Applications  
Properties & Relations  
Possible Issues  
See Also
Tech Notes
Related Guides
Related Links
History
Cite this Page

StringLength ["string"]

gives the number of characters in a string.

Details

  • StringLength counts special characters such as as single characters, even if their full names involve many characters.
  • StringLength [{s1,s2,}] gives the list of lengths of each of the si.
  • StringLength [BioSequence ["type","seq"]] will give the length of the string "seq".

Examples

open all close all

Basic Examples  (1)

Find the number of characters in a string:

Scope  (4)

Find lengths of all strings in a list:

StringLength treats special characters just like ordinary ones:

Newlines count as one character:

Find the length of a biomolecular sequence:

Applications  (1)

Find the growth rate of a string substitution system:

Properties & Relations  (2)

The empty string has zero length:

StringLength counts the underlying character codes, not selectable characters:

The length is equivalent to the length of the list returned by ToCharacterCode :

It is also equivalent to the length of the list returned by Characters :

Possible Issues  (2)

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:

See Also

Length   Characters

Tech Notes

History

Introduced in 1988 (1.0) | Updated in 1996 (3.0) 2003 (5.0) 2004 (5.1) 2020 (12.2)

Wolfram Research (1988), StringLength, Wolfram Language function, https://reference.wolfram.com/language/ref/StringLength.html (updated 2020).

Text

Wolfram Research (1988), StringLength, Wolfram Language function, https://reference.wolfram.com/language/ref/StringLength.html (updated 2020).

CMS

Wolfram Language. 1988. "StringLength." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/StringLength.html.

APA

Wolfram Language. (1988). StringLength. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StringLength.html

BibTeX

@misc{reference.wolfram_2025_stringlength, author="Wolfram Research", title="{StringLength}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/StringLength.html}", note=[Accessed: 17-November-2025]}

BibLaTeX

@online{reference.wolfram_2025_stringlength, organization={Wolfram Research}, title={StringLength}, year={2020}, url={https://reference.wolfram.com/language/ref/StringLength.html}, note=[Accessed: 17-November-2025]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /