Hi,

I'm having a very large string which as below


--------------------------------------------------------------------------------

EQD+CN+SAMPLE18767+2200+++5'
NAD+CA+FIR:172:20'
DGS+IMD+3.2+2346+55:CEL'
FTX+AAA+++GOOD'
FTX+AAA+++ONE'
....
....
EQD+CN+SAMPLE18795+2200+++5'
NAD+CA+TIR:172:20'
DGS+IMD+3.2+2346+55:CEL'
FTX+AAA+++SECOND'
FTX+AAA+++IS FAIR'
....
...
similarly FTX+AAA as above and it goes on


--------------------------------------------------------------------------------

i tokenized each segment with delimiter as ' and able to read each segment.

Now i want to concatenate the FTX+AAA in a single segment if more than one FTX+AAA with IMMEDIATE below

The output is as follows


--------------------------------------------------------------------------------
EQD+CN+SAMPLE18767+2200+++5'
NAD+CA+FIR:172:20'
DGS+IMD+3.2+2346+55:CEL'
FTX+AAA+++GOOD,ONE'
....
....
EQD+CN+SAMPLE18795+2200+++5'
NAD+CA+TIR:172:20'
DGS+IMD+3.2+2346+55:CEL'
FTX+AAA+++SECOND,IS FAIR'
....
...
similarly FTX+AAA should be concatenated if it has similar FTX+AAA IMMEDIATE below.

The FTX+AAA segments can come any number of times immediate below
--------------------------------------------------------------------------------

Please help me how we can do this??? Can anyone help me with the code snippet to do this?

Thanks,
Kathir

Please post links to other forums you've asked this on

Here, I'll post some pseudo-code for you:

boolean boolFTX=false; //Flag for your FTX+AAA
while(Read Line)
{
  if(string.indexOf("FTX+AAA")>0)
  {
    if(boolFTX)
      //Concat Strings
    else
    {
      boolFTX=true;
      //Read Normally
    }     
  else
    //Read Normally
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.