Anonymous user
Determine if a string is numeric: Difference between revisions
Updated D entry
(Updated D entry) |
|||
Line 391:
<lang d>import std.stdio, std.string, std.conv;
bool isNumeric(in string s) /*pure*/ {
try
to!real(s.strip());
Line 402:
foreach (s; ["12", " 12\t", "hello12", "-12", "02",
"0-12", "+12", "1.5"])
writeln("\nNo hex or binary conversion:");
foreach (s; ["0x10", "6b"])
}</lang>
Output:
|