Remove chars from a string to get only the numbers

garak
Member Posts: 3,263
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:
Regards
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!
2
Comments
-
Very neat, I like little tips like this.
Good for returning bank sort codes/credit card nos. etc.
Jonathan0 -
kriki mentioned such a similar code in 2006
viewtopic.php?t=14879
I've used it many times to clean up phone numbers & zip code, etc.
very useful0 -
#-o 2 years to late :oops:Do you make it right, it works too!0
-
9 years later but still THANKS!!!0
-
Nice1
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions