Delphi – How to get the first element in a string


I'm trying to figure out a way to check a string's first element if it's either a number or not.

if not(myString[0] in [0..9]) then //Do something

The problem is that I get an error "Element 0 inaccessible – use 'Length' or 'SetLength"

Another way came to my head from my C-like exprieince – convert the first element of the string to char and check the char,but there is no difference in the compile errors.

if not(char(myString[0]) in [0..9]) then //Do something

How do I accomplish it?

Best Answer

Strings are 1-based:

if not (myString[1] in ['0'..'9']) then // Do something