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

Examples

open allclose all

Basic Examples  (2)

Test if a string is valid Wolfram Language syntax:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

When SyntaxQ gives True, the string can be converted to an expression:

In[3]:=
Click for copyable input
Out[3]=

Request input from a dialog repeatedly until it is syntactically correct:

In[1]:=
Click for copyable input
Out[1]=

Scope  (2)

Properties & Relations  (2)

See Also

ToExpression  SyntaxLength  $SyntaxHandler  WolframLanguageData  DelimiterFlashTime

Tutorials

Introduced in 1991
(2.0)
| Updated in 2017
(11.1)