[Solved] c++ Check if string is valid Integer or decimal (both negative and positive cases)
The answer was a simple Regex: bool regexmatch(string s){ regex e (“[-+]?([0-9]*\.[0-9]+|[0-9]+)”); if (regex_match (s,e)) return true; return false; } It will return true on integers (i.e. 56, -34) and floating point numbers (i.e. 6.78, -34.23, 0.6) as expected. 3 solved c++ Check if string is valid Integer or decimal (both negative and positive cases)