Find multiple strings with a string

dabba23
Member Posts: 77
Hey there 
I am unsure how to write a piece code that take out multiple strings within a string.
My string can look as this:
#1234,#4567,#3456-ABJ,#9000,#9876-MEE
or
#1234,#4567,#3456-ABJ,#9876-MEE,#9000
or
#1234,#4567,#3456-ABJ,#9000
I want to take out those where there is a DASH:
#3456-ABJ and #9876-MEE
Can anyone help me
Thanks
Ann

I am unsure how to write a piece code that take out multiple strings within a string.
My string can look as this:
#1234,#4567,#3456-ABJ,#9000,#9876-MEE
or
#1234,#4567,#3456-ABJ,#9876-MEE,#9000
or
#1234,#4567,#3456-ABJ,#9000
I want to take out those where there is a DASH:
#3456-ABJ and #9876-MEE
Can anyone help me

Thanks
Ann
0
Comments
-
I think you'll have to use a combination of "SELECTSTR" (Use this function to retrieve a substring from a comma-separated string) and "STRPOS" (Use this function to search for a substring inside a string).
C/SIDE help can tell you more about these statements.
You can put the SELECTSTR into an iteration by counting the comma's. You can do that by using statements like:
strCommas := DELCHR(String,"=",DELCHR(String,'=',','));
intNumberOfCommas := STRLEN(strCommas );
I hope this is useful for you.0 -
You might also want to consider temporary tables.
First you populate the temp table with all values and then filter on '-'0 -
This is an untested sample, you may have to adjust it.
OldStr := '#1234,#4567,#3456-ABJ,#9000,#9876-MEE'; //CommaSep and Hyphon are Integers REPEAT // Find The Comma CommaSep := STRPOS(OldStr,','); IF CommaSep <> 0 Then Begin // Find the Hyphon Hyphon := STRPOS(COPYSTR(OldStr,'-',1,commaSep)); // Add Good Value add to the String IF Hyphon = 0 THEN NewStr := NewStr + CopyStr(OldStr,1,CommaSep+1); //Trim Old string OldStr := CopyStr(OldStr,CommaSep+1); End; UNTIL CommaSep = 0; // Deal with the Last String Hyphon := STRPOS(COPYSTR(OldStr,'-')); // Add Good Value add to the String IF Hyphon = 0 THEN NewStr := NewStr + OldStr; Message('%1',NewStr);
Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
Hey everyone,
Thanks for the help. I managed to sort it out with your help:)
Ann0
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