I want to check if a string is numeric.
For example:
-
"abcd123"
should returnfalse
. -
"1.4"
or"240"
should returntrue
.
I thought about using ParseInt
and ParseFloat
(from the strconv
package), but am not sure if that is the right way.
I want to check if a string is numeric.
For example:
"abcd123"
should return false
. "1.4"
or "240"
should return true
. I thought about using ParseInt
and ParseFloat
(from the strconv
package), but am not sure if that is the right way.
我要检查字符串是否为数字。 p>
例如: p>
“ abcd123” code>应该返回 false code> 。 li>
-
“ 1.4” code>或“ 240” code>应该返回 true code>。 li>
ul>
我考虑过使用 ParseInt code>和 ParseFloat code>(来自 strconv code>包) ),但不确定是否正确。 p>
div>