StringHelpers¶
IsNumeric¶
Internal helper function¶
static bool IsNumeric(const std::string str, const bool allowDecimalPoint = false)
A static helper function.
Will return true, if str is a purely numeric (base 10) string, including signage (preceding '-').
If allowDecimalPoint is set to true, it will also allow decimal values (like 0.123).
It basically says: "Can you std::stoll / std::stold this string?"
Examples:¶
StringHelpers::IsNumeric("Donald Trump") // false
StringHelpers::IsNumeric("Donald Trump5") // false
StringHelpers::IsNumeric("5Donald Trump") // false
StringHelpers::IsNumeric("12a") // false
StringHelpers::IsNumeric("0x53") // false
StringHelpers::IsNumeric("12") // true
StringHelpers::IsNumeric("-12") // true
StringHelpers::IsNumeric("12.0") // false
StringHelpers::IsNumeric("12.0", true) // true
StringHelpers::IsNumeric("12.0.5", true) // false
StringHelpers::IsNumeric("-") // false
StringHelpers::IsNumeric("-.", true) // false
StringHelpers::IsNumeric(".", true) // false