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

Encephalopathic wrote:
You've posted > 300 times here and you still don't respect the rule regarding notification of all cross-posts? [http://www.java-forums.org/advanced-java/30061-how-extract-substring-string-based-condition.html]
Do you think this this will help convince others to help you?See also [http://www.coderanch.com/t/500088/java/java/extract-substring-string-based-condition|http://www.coderanch.com/t/500088/java/java/extract-substring-string-based-condition].

Similar Messages

  • How to extract substring from string... how to find the index?

    suppose i have a string like
    "string1 string2 string3 string4 string....stringK...stringN"
    i would like to extract the substring from string4 to stringK-1
    where stringK and string3 are pre defined strings (ie, i know exactly what stringK and string3 is).
    is there a function to extract the substring from string4 to stringK-1
    or is there a function i can use to determine the index of the end of string4 and the start of stringK?
    thks!

    If your substrings are seperated by a space (or by any other character that isn't used in any of the substrings), you could use something like StringTokenizer.
    If you wanna get real fancy, use the split method of String.

  • Help: how to extract digits from a string?

    Hi,
    I am trying to make a formatted phone number report. The field is VARCHAR2(20). There might be some sort of irregularities. What I need to do are in two steps:
    1. extract all digits in order;
    2. format the output as (xxx) xxx-xxxx
    Any suggestions?
    Thank you in advance.
    Jimmy

    This might be of some use to clean up the phone numbers.
    drop   table phone_numbers;
    create table phone_numbers
    (phone      varchar2(20));
    insert into phone_numbers(phone) values ('(111)-555-1212');
    insert into phone_numbers(phone) values (' 111 555 1212');
    insert into phone_numbers(phone) values ('#555-1212');
    insert into phone_numbers(phone) values ('Bob @ 555-1212');
    commit;
    select phone, translate(phone,'0123456789()-.@#* ','0123456789') edited_phone
    from   phone_numbers;
    PHONE                EDITED_PHONE
    (111)-555-1212       1115551212
    111 555 1212        1115551212
    #555-1212            5551212
    Bob @ 555-1212       Bob5551212You can see by the last example that the search string in the translate function should contain every character you can type on a keyboard.

  • How to get substring from a string?

    For example, there is a string:
    C-REVF-00003 0010 Development
    how the program get the value '0010'?

    Hi,
    Use Split command.
    Syntax
    SPLIT <c> AT <del> INTO <c1>... <cn> INTO TABLE <itab>.
    Searches the field <c> for the character <del> and places the partial fields before and after <del>
    into the target fields <c1> … <cn>, or into a new line of the internal table <itab>.
    Ex.
    DATA: STRING(60),
    P1(20) VALUE '++++++++++++++++++++',
    P2(20) VALUE '++++++++++++++++++++',
    P3(20) VALUE '++++++++++++++++++++',
    P4(20) VALUE '++++++++++++++++++++',
    DEL(3) VALUE '***'.
    STRING = ' Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5'.
    WRITE STRING.
    SPLIT STRING AT DEL INTO P1 P2 P3 P4.
    WRITE / P1.
    WRITE / P2.
    WRITE / P3.
    WRITE / P4.
    The output appears as follows:
    Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5
    Part 1
    Part 2
    Part 3
    Part 4 *** Part 5
    Regards,
    Bhaskar

  • How to Extract Data from IT 0025 and Modify the layout for Printing

    Hi All,
    Query----> My client has a requirement to output the appraisal data in a given format from IT 0025. (The entire appraisal done for the employee)
    I would like to know from where this data will be picked up … is this data stored in some cluster table and how can we change the layout for printing in the desired format?
    Note: PA and PD is Integrated. When we create appraisal in IT 0025 no record gets created in PA0025, in which table does the record gets created and how to retrieve the data?

    hello,
    normally stored in pa0025.
    are you using the old or new appraisal system?
    if you are using the new one. its not stored in pa0025 it is done with relationships..
    regards
    stefan

  • How to calc sum of one column, based on the condition of another column?

    I would like to create a formula that adds up the total cost from column F for each specified service in column D. For example, the result for PM (project management) would be $495. Any ideas?

    I think you could use this formula, using your cell references:
    =SUMIF(D4:D21,"=CM",F4:F21)
    Then, change the "=CM' to "=PM", etc. for each service.
    Like JaxJason, I can't test this in Numbers right now, but it works in Excel, and the functions are identical.
    SUMIF(test-range, "condition", [sum-range]):
    * test-range: A reference to the range of cells containing values to test. Must be the same dimensions as sum-range.
    * "condition": Any comparison statement that results in a logical TRUE or FALSE value.
    * sum-range: Optional; a reference to the range of cells containing the numbers to be added. Must have the same dimensions as test-range. If omitted, test-range is used.
    I hope this helps.
    - Michael
    Message was edited by: Apple fan Michael

  • How to extract certificates from IE for digital signature

    hi
    how to extract certificates from the cert store provided by Internet Explorer 6.0 and use it to read & verify the digital signatures present in the pc.this is needed in my web based application n i have no idea!!!
    pls help me out
    i have studied a lot about all JCA n JCE but the extraction part still baffles me!!!
    my application will be java based so i can make an applet/ servlet/ jsp
    drop your ideas as soon as u get time as i am stuck in the initial phase itself
    priya_16

    hi
    i've the same problem. i've found this solution, but you need download a JCE Provider that allow you to read the explorer certificate store.
    You can try this one: https://download.assembla.se/jceprovider/
    and the code:
    import se.assembla.*;
    public class Listcerts {  
         public static void list() throws Exception{
              java.security.Security.insertProviderAt(new se.assembla.jce.provider.ms.MSProvider(), 2);
              KeyStore ks = KeyStore.getInstance("MSKS","assembla");
              ks.load(null,null);
              X509Certificate cert=null;
              String alias=null;
              int count=0;
              for (java.util.Enumeration e=ks.aliases();e.hasMoreElements();){
                        alias=(String)e.nextElement();
                        cert=(X509Certificate)ks.getCertificate(alias);
                        System.out.println("\n Certificado alias"+alias+":");
                        System.out.println(cert);
                   count++;
              System.out.println ("NUM CERTS="+count);
    now, i need the same solution for Firefox browser XP
    good luck
    Message was edited by:
    meteko

  • How to extract text from a PDF file?

    Hello Suners,
    i need to know how to extract text from a pdf file?
    does anyone know what is the character encoding in pdf file, when i use an input stream to read the file it gives encrypted characters not the original text in the file.
    is there any procedures i should do while reading a pdf file,
    File f=new File("D:/File.pdf");
                   FileReader fr=new FileReader(f);
                   BufferedReader br=new BufferedReader(fr);
                   String s=br.readLine();any help will be deeply appreciated.

    jverd wrote:
    First, you set i once, and then loop without ever changing it. So your loop body will execute either 0 times or infinitely many times, writing the same byte every time. Actually, maybe it'll execute once and then throw an ArrayIndexOutOfBoundsException. That's basic java looping, and you're going to need a firm grip on that before you try to do anything as advanced as PDF reading. the case.oops you are absolutely right that was a silly mistake to forget that,
    Second, what do the docs for getPageContent say? Do they say that it simply gives you the text on the page as if the thing were a simple text doc? I'd be surprised if that's the case.getPageContent return array of bytes so the question will be:
    how to get text from this array? i was thinking of :
        private void jButton1_actionPerformed(ActionEvent e) {
            PdfReader read;
            StringBuffer buff=new StringBuffer();
            try {
                read = new PdfReader("d:/getjobid2727.pdf");
                read.getMetaData();
                byte[] data=read.getPageContent(1);
                int i=0;
                while(i>-1){ 
                    buff.append(data);
    i++;
    String str=buff.toString();
    FileOutputStream fos = new FileOutputStream("D:/test.txt");
    Writer out = new OutputStreamWriter(fos, "UTF8");
    out.write(str);
    out.close();
    read.close();
    } catch (Exception f) {
    f.printStackTrace();
    "D:/test.txt"  hasn't been created!! when i ran the program,
    is my steps right?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to extract data from planning book

    nu t apo. need help regarding how to extract data from planning book givn the planning book name , view name & some key figures.
    Total Demand (Key Figure DMDTO):
    o     Forecast
    o     Sales Order
    o     Distribution Demand (Planned)
    o     Distribution Demand (Confirmed)
    o     Distribution Demand (TLB-Confirmed)
    o     Dependent Demand
    Total Receipts (Key Figure RECTO):
    o     Distribution Receipt (Planned)
    o     Distribution Receipt (Confirmed)
    o     Distribution Receipt (TLB-Confirmed)
    o     In-Transit
    o     Production (Planned)
    o     Production (Confirmed)
    o     Manufacture of Co-Products
    Stock on Hand (Key Figure STOCK):
    o     Stock on Hand (Excluding Blocked stock)
    o     Stock on Hand (Including Blocked stock)
    In-Transit Inventory (Cross-company stock transfers)
    Work-in-progress (Planned orders / Process orders with start date in one period and finish date in another period)
    Production (Planned), Production (Confirmed) and Distribution Receipt elements need to be converted based on Goods Receipt date for projected inventory calculation.

    Hello Debadrita,
    Function Module BAPI_PBSRVAPS_GETDETAIL2 or BAPI_PBSRVAPS_GETDETAIL can help you.
    For BAPI BAPI_PBSRVAPS_GETDETAIL, the parameters are:
    1) PLANNINGBOOK - the name of your planning book
    2) DATA_VIEW - name of your data view
    3) KEY_FIGURE_SELECTION - list of key figures you want to read
    4)  SELECTION - selection parameters which describe the attributes of the data you want to read (e.g. the category or brand). This is basically a list of characteristics and characteristic values.
    BAPI_PBSRVAPS_GETDETAIL2 is very similar to BAPI_PBSRVAPS_GETDETAI but is only available from SCM 4.1 onwards.
    For the complete list of parameters, you can go to transaction SE37, enter the function module names above and check out the documentation.
    Please post again if you have questions.
    Hope this helps.

  • How to extract data From Hyperion Essbase to Flat Files

    Hi ,
    Can anyone tell me how to extract data from Hyperion essbase to Flat file(e.g. .csv , .txt ,...) or Oracle Table using ODI.
    Regards,
    Avneet

    Hi sutirtha,
    I have make one column as key column now i am getting this error,
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 1, in ?
    com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at com.hyperion.odi.essbase.ODIEssbaseDataReader.getAppData(Unknown Source)
    at com.hyperion.odi.essbase.AbstractEssbaseReader.extract(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
    at org.python.core.PyMethod.__call__(PyMethod.java)
    at org.python.core.PyObject.__call__(PyObject.java)
    at org.python.core.PyInstance.invoke(PyInstance.java)
    at org.python.pycode._pyx7.f$0(<string>:1)
    at org.python.pycode._pyx7.call_function(<string>)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyCode.call(PyCode.java)
    at org.python.core.Py.runCode(Py.java)
    at org.python.core.Py.exec(Py.java)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:144)
    at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.k(e.java)
    at com.sunopsis.dwg.cmd.g.A(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)
    Caused by: com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at com.hyperion.odi.essbase.wrapper.EssbaseReportDataIterator.validateColumns(Unknown Source)
    at com.hyperion.odi.essbase.wrapper.EssbaseReportDataIterator.init(Unknown Source)
    ... 33 more
    com.hyperion.odi.essbase.ODIEssbaseException: com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
    at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.k(e.java)
    at com.sunopsis.dwg.cmd.g.A(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)

  • Cut Substring from a string

    Hi!
    I have a question
    Can i cut a substring from a string?
    If yes how is possible?
    Can you help me with an example?
    Thanks

    Hi!
    I have a question
    Can i cut a substring from a string?Yes
    If yes how is possible?You shoould read the API for String, there is a method called substring
    Can you help me with an example?You wont need one if you read the API

  • How to extract text from a PDF file using php?

    How to extract text from a PDF file using php?
    thanks
    fabio

    > Do you know of any other way this can be done?
    There are many ways. But this out of scope of this forum. You can try this forum: http://forum.planetpdf.com/

  • How to extract data from SAP in FDM 11121

    I came across some documents from version 11113, says there is a SAP adapter, however ,when I check 11121 there's no such adapter, does anyone know how to extract data from SAP in FDM 11121?

    I download a package from Bristlecone, but I dont see any xml files in it, just a bunch of dll and I didn't find any instructions on how to set up/configure in FDM, it just explained how to register in SAP app server and client.
    Hyperion 11113 has readme on sap adapter(Hyperion Readme Template), but I cannot find the same readme file in 11121, all I can find is ERP Integration Adapter document. any idears where I can find at least a readme document?

  • How to extract data from web URL

    I was doing one project which need to extract data from web pages and then analyze these data. the question is how to extract data from there, using html parser? need help, thanks a lot

    I was doing one project which need to extract data
    from web pages and then analyze these data. the
    question is how to extract data from there, using
    html parser? need help, thanks a lotTry this:
    http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html
    Or, like you said yourself, use an HTML parser:
    http://java-source.net/open-source/html-parsers

  • How to extract data from Chart History?

    Dear all, I have read a lot of posts, but still don't understand how to extract data from Chart history.
    Suppose you acquired 1024 points of data every time, then use "build array" to build an array, then send to intensity chart to show, then save the history into a .txt file,  but how to extact data from the file?
    How Labview store the data in the 2D history buffer?
    Anybody has any examples?

    The simplest would be to save the 2D array as a spreadsheet file, the read it back the same way.
    Maybe the attached simple example can give you some ideas (LabVIEW 7.1). Just run it. At any time, press "write to file". At any later time, you can read the save data into the second history chart.
    If you are worried about performance, it might be better to use binary files, but it will be a little more complicated. See how far you get.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    IntensityChartHistorySave.vi ‏79 KB

Maybe you are looking for

  • How can I tell if my ipod touch turns on?

    My screen is broken -- with ink coming out of it. How do I know if it turns on so that I only buy a screen replacement?

  • Specify filter for every request except one

    Can a in me web.xml file specify that a filter should be used for every request except one. I can write; <filter-mapping>      <filter-name>MyFilter</filter-name>           <url-pattern>/*</url-pattern> </filter-mapping> to use it on every request. B

  • Canon iP4500 - Switch OFF Color Management in Leopard 10.5.3

    Hello, a few days ago I've got the Canon iP4500; I've downloaded the latest drivers for it (on the Canon web called 2.1, but when installed it says 10.1). I wanted to profile the printer with the EyeOnePhoto spectrometer, so I logically wanted to swi

  • Making a Media Player

    How would I go about doing this? Are there any resources that can help me get started? I know next to nothing about Java.

  • AAE configuration

    Hi experts, I am configuring  the interface PROXY >PI>JMS using AAE features. I created required IR objects. Then I am configuring my interface with ICO. Here i am trying to add my created sender communication channel as SOAP (for Proxy with message