Function std.string.isNumeric
[in] string s
can be formatted in the following ways:
Integer Whole Number:
(for byte, ubyte, short, ushort, int, uint, long, and ulong)
['+'|'-']digit(s
)[U|L|UL]
Prototype
bool isNumeric( const(char)[] s, const(bool) bAllowSep = false ) pure @safe;
examples
123, 123UL, 123L, +123U, -123L
Floating-Point Number:
(for float, double, real, ifloat, idouble, and ireal)
['+'|'-']digit(s
)[.][digit(s
)][[e-|e+]digit(s
)][i|f|L|Li|fi]]
or [nan|nani|inf|-inf]
examples
+123., -123.01, 123.3e-10f, 123.3e-10fi, 123.3e-10L
(for cfloat, cdouble, and creal)
['+'|'-']digit(s
)[.][digit(s
)][[e-|e+]digit(s
)][+]
[digit(s
)[.][digit(s
)][[e-|e+]digit(s
)][i|f|L|Li|fi]]
or [nan|nani|nan+nani|inf|-inf]
examples
nan, -123e-1+456.9e-10Li, +123e+10+456i, 123+456
[in] bool bAllowSep
False by default, but when set to true it will accept the
separator characters ','
and '_'
within the string, but these
characters should be stripped from the string before using any
of the conversion functions like toInt(), toFloat(), and etc
else an error will occur.
Also please note, that no spaces are allowed within the string
anywhere whether it's
a leading, trailing, or embedded space(s
),
thus they too must be stripped from the string before using this
function, or any of the conversion functions.
Authors
Walter Bright, Andrei Alexandrescu, and Jonathan M Davis