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.

Similar Messages

  • 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].

  • How to get substring from string starting from the end of string

    Hi
    How to cut from string:
    $A=C:\ClusterStorage\Volume1\WXP-plwropc300\Virtual Hard Disks\WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    this substring (name of VHD file): WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    This script should be universal so the best way to be cut all leters from the end of string $A till get the first mark \
    Thank you for help.
    Tomasz
    Kind Regards Tomasz

    PS > Split-Path 'C:\ClusterStorage\Volume1\WXP-plwropc300\Virtual Hard Disks\WXP-PLWROPC300_EE20E00F-315E-4781
    -A6DE-68497D4189B8.avhdx' -leaf
    WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    PS >
    That is what "Split-Path" is for:
    ¯\_(ツ)_/¯

  • How to get substring from string using index?

    hi,
    here i am having string ,
    i want the pullareddy from below line ,
    i know how to get from substring.
    but i want to get the above using "index",
    can any help how to do it?
    String str1="janapana,pullareddy, in malaysia";
    jpullareddy

    get the start index with indexAt("pullareddy")
    get the end index with adding the length of the word to the start
    get the char[] of str1 with toCharArray()
    make a new string with the chars from start to end index.

  • Need a way to extract substring from string in oracle

    Hi all,
    I have one requirement related to extracting string from a paramater.
    suppose the string may like this in various format
    string:= 'This my string <Rid//problem/123456>'
    or
    string:= '<Rid//problem/123456> This my string'
    or
    string:= ' This is <Rid//problem/123456> my string'
    Now my requirement is i need to extract 123456 using pl/sql block.
    is there any way in oracle to get this thing done.
    Thanks n regards
    Laxman

    Hi,
    What version of Oracle ?
    How do you delimit the string to extract ?
    - always between the last / and before the >
    - the last string mande of number ?
    - the first string made of number ?
    Here are 3 possible answers :SQL> with s as (
      2  select 'This my string <Rid//problem/123456>' s from dual
      3  union all select '<Rid//problem/123456> This my string' from dual
      4  union all select ' This is <Rid//problem/123456> my string' from dual
      5  )
      6  select s.s,
      7  regexp_replace(s,'^.*/([0-9]*).*$','\1') r1,
      8  regexp_replace(s,'^[^0-9]*(.*?)[^0-9]*$','\1') r2,
      9  regexp_replace(s,'^.*/(.*?)>.*$','\1') r3
    10  from s ;
    S                                        R1       R2       R3
    This my string <Rid//problem/123456>     123456   123456   123456
    <Rid//problem/123456> This my string     123456   123456   123456
    This is <Rid//problem/123456> my string 123456   123456   123456If you're on 10g or more...
    Of course it also works in PL/SQL :SQL> l
      1  declare
      2  r1 varchar2(50) := 'This my string <Rid//problem/123456>';
      3  r2 varchar2(50) := '<Rid//problem/123456> This my string';
      4  r3 varchar2(50) := ' This is <Rid//problem/123456> my string';
      5  r1b varchar2(50);
      6  r2b varchar2(50);
      7  r3b varchar2(50);
      8  begin
      9  r1b := regexp_replace(r1,'^.*/([0-9]*).*$','\1') ;
    10  r2b := regexp_replace(r2,'^[^0-9]*(.*?)[^0-9]*$','\1') ;
    11  r3b := regexp_replace(r3,'^.*/(.*?)>.*$','\1') ;
    12  dbms_output.put_line('1 : '||r1||' -> '||r1b);
    13  dbms_output.put_line('2 : '||r2||' -> '||r2b);
    14  dbms_output.put_line('3 : '||r3||' -> '||r3b);
    15* end;
    SQL> /
    1 : This my string <Rid//problem/123456> -> 123456
    2 : <Rid//problem/123456> This my string -> 123456
    3 :  This is <Rid//problem/123456> my string -> 123456
    PL/SQL procedure successfully completed.Edited by: Nicosa on Jul 23, 2010 3:22 PM

  • 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

  • Extract substring from string

    Hi,
    Iu2019m reaching out to the experts in the forum for assistance with resolving a code issue in Universe Designer u2013 itu2019s not producing the expected result.  The following are details, and steps taken:
    Objective: To extract only the characters between #u2019s, i.e. u2013 Smith, John added comments on 12/1/11 V5M#0.25# this is a test.  *NOTE* The characters before AND after the #u2019s varies.
    Database u2013 Oracle 10g
    Field type u2013 CLOB (DBAu2019s will not change) u2013 I created an object u201CDescriptionu201D= DBMS_LOB.SUBSTR("Oracle_Test_Unv". DESC, 4000,1) u2013 I also tried casting as a varchar2 and still the same result.
    Object u2013 Code to extract the characters between #u2019s:
         CASE WHEN @Select(Oracle_Test_Unv\Description) LIKE '%V5M#%#%'
                             THEN DBMS_LOB.SUBSTR(@Select(Oracle_Test_Unv\Description),
                                    DBMS_LOB.INSTR(@Select(Oracle_Test_Unv\Description), '#',1,1)+1,
                                          DBMS_LOB.INSTR(@Select(Oracle_Test_Unv\Description), '#',1,2) -
                                               DBMS_LOB.INSTR(@Select(Oracle_Test_Unv\Description), '#',1,1)-1)
                                                    ELSE '0'
                                                          END
    Current Result:  Smith, John added comments on 12/1/11 V5M#0.25
    Thanks in advance for your help!

    Apologies, I forgot to include the expected result.  Please see below:
    Expected result: 0.25
    Thanks again!

  • 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 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 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)

  • 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

  • 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.

Maybe you are looking for

  • Customizing a query for a report according to login user name

    Hi, I am new to the portal, so I have a urgent question: In my company we have local departments who are supposed to use the same report but only with their own data. I have a table with all users and their parameters (e.g. username + deptno) and mig

  • How to save .pdf file using office word and excel

    Can someone help me how to save .pdf files using office word and excel?  I reinstalled my adobe 7.0 pro in my new pc and before I was able to do it but with my old pc.

  • Batch Split in MB1A

    Dear Friends, Please let me know... whether can we do the batch splitting & Batch determination in the transaction MB1A (to production order movement 261). If Yes... How can we do it. I know that after doing the component splitting in the production

  • What can i do if my ipod fell down in to the wather

    What can i do if my ipod nano fell down in to the wather? i can`t turn on my ipod! and it has garanty. i`m from  Mexico, Campeche!

  • One small problem

    Program Description There is a group of mountain climbers. This program shows all possible combinations of mountain climbers if they are put into teams of 3. The user inputs the number of mountain climbers. Output uses letters to represent each mount