SyntaxQ
SyntaxQ["string"]
returns True if the string corresponds to syntactically correct input for a single Wolfram Language expression, and returns False otherwise.
SyntaxQ["string",form]
uses interpretation rules corresponding to the specified form.
Details
- If SyntaxQ returns False, you can find the position of a syntax error using SyntaxLength.
- form can be InputForm, StandardForm, TeXForm, TraditionalForm, or MathMLForm.
Examples
open allclose allBasic Examples (2)
Scope (2)
Verify a TeXForm input:
This can be converted to a Wolfram Language expression:
SyntaxQ can verify strings containing StandardForm or TraditionalForm boxes:
It does not accept the boxes themselves:
Properties & Relations (2)
The default interpretation form is InputForm:
This input is valid MathMLForm:
Use SyntaxLength to find the longest leading substring which is syntactically valid:
Text
Wolfram Research (1991), SyntaxQ, Wolfram Language function, https://reference.wolfram.com/language/ref/SyntaxQ.html (updated 2017).
CMS
Wolfram Language. 1991. "SyntaxQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/SyntaxQ.html.
APA
Wolfram Language. (1991). SyntaxQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SyntaxQ.html