Results 1 to 6 of 6
  1. #1
    j_kathiresan is offline Member
    Join Date
    Feb 2008
    Posts
    12
    Rep Power
    0

    Default How to extract substring from a string based on the condition ??

    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

  2. #2
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    4

    Default

    Cross-post: Java Programming - How to extract substring from a string based on the condition ??

    Please read the FAQ regarding cross-posts.

  3. #3
    j_kathiresan is offline Member
    Join Date
    Feb 2008
    Posts
    12
    Rep Power
    0

    Default

    Sorry i thought this was a different forum.

    Please help.

    Thanks,
    Kathir

  4. #4
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    4

    Default

    Quote Originally Posted by j_kathiresan View Post
    Sorry i thought this was a different forum.
    Different forum? How the heck does that matter? Please read the link: BeForthrightWhenCrossPostingToOtherSites

    Then please post all links to cross-posts.

  5. #5
    j_kathiresan is offline Member
    Join Date
    Feb 2008
    Posts
    12
    Rep Power
    0

    Default

    I read the contents. Sorry about that. i'll make sure that i don't cross post the same matter.

    Thanks.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    It's not about not cross posting.
    It's about keeping the sites you post to informed that you have posted the question elsewhere, with a link.

Similar Threads

  1. Concatinating contents of a string array based on condition
    By gangsterooseven in forum Advanced Java
    Replies: 2
    Last Post: 10-07-2009, 07:35 AM
  2. IF-Condition in a String
    By lenaz in forum Advanced Java
    Replies: 1
    Last Post: 07-18-2009, 12:07 PM
  3. Reverse a string not using the substring method
    By kathyla18 in forum New To Java
    Replies: 17
    Last Post: 04-08-2009, 04:08 AM
  4. String substring function
    By ravian in forum New To Java
    Replies: 6
    Last Post: 01-02-2008, 07:35 PM
  5. problem with using string in if condition
    By sireesha in forum New To Java
    Replies: 2
    Last Post: 11-20-2007, 10:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •