SyntaxLength

SyntaxLength["string"]

finds the number of characters starting at the beginning of a string that correspond to syntactically correct input for a single Wolfram Language expression.

Details

  • SyntaxLength effectively returns the position of a syntax error, if one exists.
  • If SyntaxLength returns a position past the end of the string, it indicates that the string is syntactically correct as far as it goes, but needs to be continued in order to correspond to input for a complete Wolfram Language expression.

Examples

Basic Examples  (1)

Give the length of the syntactically correct beginning substring:

The syntactically correct part can be converted to an expression:

Wolfram Research (1991), SyntaxLength, Wolfram Language function, https://reference.wolfram.com/language/ref/SyntaxLength.html.

Text

Wolfram Research (1991), SyntaxLength, Wolfram Language function, https://reference.wolfram.com/language/ref/SyntaxLength.html.

CMS

Wolfram Language. 1991. "SyntaxLength." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SyntaxLength.html.

APA

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

BibTeX

@misc{reference.wolfram_2024_syntaxlength, author="Wolfram Research", title="{SyntaxLength}", year="1991", howpublished="\url{https://reference.wolfram.com/language/ref/SyntaxLength.html}", note=[Accessed: 03-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_syntaxlength, organization={Wolfram Research}, title={SyntaxLength}, year={1991}, url={https://reference.wolfram.com/language/ref/SyntaxLength.html}, note=[Accessed: 03-December-2024 ]}