MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need a code to split on characters for the Below Example

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
vraki
Beginner


Joined: 07 Jun 2006
Posts: 11
Topics: 7
Location: India

PostPosted: Mon Jul 02, 2007 4:36 am    Post subject: Need a code to split on characters for the Below Example Reply with quote

Example: Records is

I, am a, "very", "Good,person.",

We need to split this example by delimiter comma.

The result should be
First Second Third Fourth
I am a very Good person

Here "Good,person.", split as only one split irrespective of comma in between.

How can we do this, please help me out....?
_________________
Raki
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Mon Jul 02, 2007 6:05 am    Post subject: Reply with quote

what language do you plan on using for your solution? pick one!
This seems like a school problem.
I assume your expected output is:
Code:

1st      I
2nd      am a 
3rd      very 
4th      Good person


you actually have two delimiters. comma and double-quotes, which override the normal comma delimiter.

define a one dimensional table to contain double-quote positions, i.e. low-high range for each group
define a two dimensional table to handle the groups and sub-groups, i.e. primary dimension would contain groups, secondary dimension would contain the UNSTRING/PARSE of a group that was not bounded by double-quotes.

  1. build a table of double-quote positions
  2. UNSTRING or PARSE the input by the double-quotes, keeping track of the number of characters in each group
    • if the group came from a double-quote front & back delimited section of the input, change comma to space
    • if group did not have a front&back double-quote, UNSTRING/PARSE the group into subgroups delimted by comma, and space out the group
  3. move non-space groups, sub-groups to final definitions

_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group