That one will work with the characters mentioned. If your string looks like below, you have to change your definition. Or use a code like this:
(txString = Text, coNumber = Code, i = Integer)
txString := ‘#asdf-64’;
FOR i := 1 TO STRLEN(txString) DO
IF (COPYSTR(txString, i, 1) >= ‘0’) AND (COPYSTR(txString, i, 1) <= ‘9’) THEN
coNumber := coNumber + COPYSTR(txString, i, 1);
//Now txString is intact; coNumber is ‘64’
REM: You cannot use syntax “coNumber += COPYSTR(txString, i, 1);” as this does not work on Code.
Here’s my implementation, which in a way is kind of similar to LHI, since I also use a lookup string
but instead of looking at characters to exclude, I’ve opted to for a lookup string that include only the characters to allow (since there are only 10 of them) and since there aretoo many characters to exclude, beside the Alphabets (lower & upper caser), they can enter stuffs lile _ % + - ! & ( )
I guess the solution above should be reliable & robust enough, and is also flexible , if you wanted to add characters to allow in your input,just add them in the lookup string (NumbersOnlyLOC), and the rest of the code will remaint the same
NumbersOnlyLOC := ‘01234567890’; // Lookupstring of characters to allow
CleanedString := ‘’;
FOR i := 1 TO STRLEN (NumbersStringPAR ) DO
BEGIN
CurrCharLOC := COPYSTR(NumbersStringPAR, i, 1);
IF STRPOS(NumbersOnlyLOC, CurrCharLOC ) <> 0 THEN
CleanedString := CleanedString + CurrCharLOC;
END;