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.
Please visit the official Wolfram Language Reference for more details and examples on core symbols.