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.
Examples
Check valid syntax:
SyntaxQ["1 + 2"]
(* True *)Invalid syntax:
SyntaxQ["1 + "]
(* False *)Please visit the official Wolfram Language Reference for more details.