I would like to test strings to see if they represent numbers. This should include number representations with precision marks and scientific notation. NumberString
is unfortunately more restrictive:
mylist = {"1.23", "1.23`", "1.23*^4", "Print[fail]"};
StringMatchQ[mylist, NumberString]
(* {True, False, False, False} *)
As a complication, I want to avoid converting the strings to expressions and testing with NumberQ
, as some strings may contain code which is unsafe to evaluate.
How can I make a pattern like NumberString
but which matches all of the first three elements in mylist
?
"EulerGamma"
to be considered a number, or are you referring to number in the sense ofNumberQ
? $\endgroup$