Using:
function IsCharNumeric(ch: Char): Boolean; begin //We have IsCharAlphaNumeric, and IsCharAlpha //So IsCharNumeric = IsCharAlphaNumber - IsCharAlpha Result := IsCharAlphaNumeric(ch) and (not IsCharAlpha(ch)); end;
Below are the test results for the selected characters.
Note : any character omitted is not numeric:
IsCharNumeric Code Symbol
- 32 "
(space) ": No - 33 "
! ": No - 34 "
" ": No - 35 "
# ": No - 36 "
$ ": No - 40 "
( ": No - 41 "
) ": No - 43 "
+ ": No - 44 "
, ": No - 45 "
- ": No - 46 "
. ": No - 48 "
0 ": Yes - 49 "
1 ": Yes - 50 "
2 ": Yes - 51 "
3 ": Yes - 52 "
4 ": Yes - 53 "
5 ": Yes - 54 "
6 ": Yes - 55 "
7 ": Yes - 56 "
8 ": Yes - 57 "
9 ": Yes - 65 "
A ": No - 66 "
B ": No - 67 "
C ": No - 68 "
D ": No - 69 "
E ": No - 70 "
F ": No - 178 "
ยฒ ": Yes - 179 "
ยณ ": Yes - 185 "
ยน ": Yes
So, if you want to trim a string to only characters that can be parsed into a number, you lose:
But the gain
On the other hand, some characters fail in the IsCharAlphaNumeric test when you think they pass:
!"#$%&'()*+,-./
The first ASCII character to pass the IsCharAlphaNumeric test is actually zero ( 0 ).
source share