Remove chars from a string to get only the numbers

garakgarak Member Posts: 3,263
edited 2009-02-15 in NAV Tips & Tricks
Last night i must from a string eleminate all chars (like 'Ak;%') that are not a number (like 7 2 3 5 0).

I was to lazy to solved this with a "loop" (for i = 1 to strlen(TextVariable)).
So i taked a look into the systemvariables of type sting.
I know that delchr() is very powerful. So the solution was very easy:
a -> Textvariable <-- the base
b -> Textvariable <-- the numbers

a := '{a4"B567/0?r45-'; //from this string i need only the numbers
b := DELCHR(a,'=',DELCHR(a,'=','1234567890')); //now, "b" contains only 4567045

Regards
Do you make it right, it works too!

Comments

Sign In or Register to comment.