use a deterministic finite automaton model

// test cases

int main()
{
    cout << "positive:" << endl;
    cout << "12345:" << isNumber("12345") << endl; 
    cout << " 12345:" << isNumber(" 12345") << endl; 
    cout << "12345 :" << isNumber("12345 ") << endl; 
    cout << ".12345 :" << isNumber(".12345 ") << endl; 
    cout << "+.12345 :" << isNumber("+.12345 ") << endl; 
    cout << "-.12345 :" << isNumber("-.12345 ") << endl; 
    cout << " 12345 :" << isNumber(" 12345 ") << endl; 
    cout << "12.345:" << isNumber("12.345") << endl; 
    cout << "1E2345:" << isNumber("1E2345") << endl; 
    cout << "1E-2345:" << isNumber("1E-2345") << endl; 
    cout << "-1.232E-2345:" << isNumber("-1.232E-2345") << endl; 
    cout << " -1.232E-2345:" << isNumber(" -1.232E-2345") << endl; 
    cout << "3.:" << isNumber("3.") << endl; 
    cout << "3. :" << isNumber("3. ") << endl; 

    cout << "negative:" << endl;
    cout << ".:" << isNumber(".") << endl; 
    cout << "T:" << isNumber("T") << endl; 
    cout << "T1:" << isNumber("T1") << endl; 
    cout << "6 .:" << isNumber("6 .") << endl; 
    cout << "-:" << isNumber("-") << endl; 
    cout << "E:" << isNumber("E") << endl; 
    cout << " :" << isNumber(" ") << endl; 
    cout << "E10:" << isNumber("E10") << endl; 
    cout << "E0:" << isNumber("E0") << endl; 
    cout << " E0:" << isNumber(" E0") << endl; 
    cout << "E-2345:" << isNumber("E-2345") << endl; 
    cout << "E2345:" << isNumber("E2345") << endl; 
    cout << "12 345:" << isNumber("12 345") << endl; 
    cout << "123.4.5:" << isNumber("123.4.5") << endl; 
    cout << "1E23.45:" << isNumber("1E23.45") << endl; 
    cout << " -1.232E -2345:" << isNumber(" -1.232E -2345") << endl; 
    return 0;
}