I need to check if a string is of the form of a decimal/ float number.
I have tried using isdigit() and isdecimal() and isnumeric(), but they don't work for float numbers. I also can not use try: and convert to a float, because that will convert things like " 12.32" into floats, even though there is a leading white-space. If there is leading white-spaces, I need to be able to detect it and that means it is not a decimal.
I expect that "5.1211" returns true as a decimal, as well as "51231". However, something like "123.12312.2" should not return true, as well any input with white-space in it like " 123.12" or "123. 12 ".
floataccepts, you need to give a clear specification of what is acceptable. For example: should.12be accepted?12.?1e6?+1.23?123_456.789?−123(with a Unicode minus sign)?