say the string you want to turn into a number is in the variable S
a=tonumber(S)
provided that there are numbers and only numbers in S
it will return a number,
but if there are any characters that are not numbers (except periods for floats)
it will return nil