Given a string as an input, your task is to check whether or not that string is a number.
What is a number?
This is a list of all input formats that are "numbers":
- Integers: An integer is a string made entirely of characters from
1234567890, without any other character e.g.
- Floats: A float is a integer with 1 (no more, no less) decimal points (
.) in the middle of the number. A decimal point must always be preceded and followed by a number e.g.
- Complex: A complex number is a number that follows the format
bare numerical values. The plus sign can also be a minus sign e.g.
143-1j. If it saves bytes (or you want to), you may use
- Longs: A long is any number that would be classed as an integer or a float, with an
Lat the end e.g
- Hexadecimal: A hexadecimal number is a number which consists entirely of characters in
1234567890abcdef. Upper case characters are valid hex, but only when used consistently e.g.
- Scientific: A scientific number is a number which consists of a run of digits (
1234567890.) followed by an
efollowed by a run of digits, optionally preceded by a
Emay also be used.
Any of these 5 may also be preceded by a minus sign (
-) but any whitespace in the number causes it to no longer be a number e.g.
-3.5 + 2i isn't a number. Longs may not be hexadecimal but may be floats
You must output 2 distinct values (preferably truthy and falsy but you may choose) for inputs that are either numbers as defined above, or not.
These should result in truthy
10 -9.34 -3.5+2j ab1 100000L 3.14159L -73e-7 7E53C80 1.2e3 12E3.4
And these should be falsy
abcdefghijklmnop 10.10.10 2569LL 10L+9j 8+45io 4aE3 3. .3
Now because small numbers are easier to work with, this is a code-golf so shortest code, in bytes, wins!