0

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

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by nbaztec
0

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
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.