Splitting a string with a delimiter

Hi,
Below are the lines of code in ABAP.
v_gpdwstring(17)             TYPE c,
v_afterdec(3)                TYPE c,
v_beforedec(10)              TYPE c,
SPLIT v_gpdwstring AT '.' INTO v_beforedec v_afterdec.
The test value for v_gpdwstring = "1.53-"
when the above SPLIT command is executed,
v_beforedec is returning blank and v_afterdec is returning 53-
Can anyone tell why v_beforedec is returning blank.
Thanks

Hello Radhika,
When I look at this, it seemed ok.
So I've tested like this:
DATA:                                                    
v_gpdwstring(17)             TYPE c,                     
v_afterdec(3)                TYPE c,                     
v_beforedec(10)              TYPE c.                                                                               
break-point.                                             
v_gpdwstring = '1.53-'.                                                                               
SPLIT v_gpdwstring AT '.' INTO v_beforedec v_afterdec.   
And the result was correct:  v_beforedec as '1', v_afterdec as '53-'.
Can you re-check please? It seems ok...
Kind regards,
Bruno

Similar Messages

  • How to split a string with a delimiting regular expression like "\r"

    Hello!I am a fresh in java programming.Please don't deride my question.What I want to realize is to get the current caret lines and cols in a JTextPane. My question is :After I fetch the string content of the JTextPane and try to split it with the end-line token like "\r" or "\r\n",it always comes me an wrong position.
    here is my code:
    public void caretUpdate(CaretEvent e) {
    int ln,col;
    JTextPane textSource = (JTextPane)e.getSource();
    String sourceString = textSource.getText();
    String subString = sourceString.substring(0,
         (e.getDot() == 0) ? 0 : e.getDot()-1);
    String[] splitString = subString.split("\r",-1);
    ln = splitString.length;
    col = e.getDot() - subString.lastIndexOf("\r");
    setCaretPosition(ln,col); //display ln and col in a label
    I have got puzzled>_<.Please help me.Any help would be appreciated . (^-^)

    Swing text components always use "\n" to separate lines, not "\r" or "\r\n". When you read text in from a file or paste from the clipboard, the line separators are converted to "\n" if necessary. They save the info about what line separators were used in the source file, so if you write the text back to a file it converts them back.

  • How to split a string with linefeed character ( LF ) as a delimiter in VB6?

    Hi. I am writing a small program in VB 6.0. 
    I have a string named Data and it contains few characters along with <LF> in it. ( <LF> is a new line/line feed character).
    I want to split this string with <LF> as delimiter and store the tokens in an array. I tried with split function and its giving me type mismatch error. Can anyone tell me how to do it?
    I am giving the pseudo-code below.
    Dim Data as string
    Data = "hello, how are you<LS>good morning guys <LS> hi"
    Dim strarray() as stringMsgbox(Data)
    strarray = split(Data, "<LS>")
    When i see the Data in message box before split function, it shows up in different lines like this:
    hello, how are you
    good morning   guys 
    hi
    I want the final array strarray to be like this:   strarray(0) = "hello, how are you"
    strarray(1) = "good morning   guys "
    strarray(2)  = " hi"
    The spaces can be as it is. Just i need the string to be delimited wherever <LS> is there.
    Please help me as soon as possible. Though it is small one, i am stuck here.
    Thanks in advance,
    Satya.

    Hello,
    This forum is for VB.NET, please check the following resources
    http://www.vbforums.com/forumdisplay.php?1-Visual-Basic-6-and-Earlier
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b/where-to-post-your-vb-6-questions?forum=vbgeneral
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • How to split a string with regular expression

    Hi.
    I need to split a string with a regular expression.
    Example
    String = "this is; a test";rune haavik;12345;
    And I want the output to be:
    "this is; a test"
    rune haavik
    12345
    If I use this code:
    private void test1()
    String str = "\"this is; a test\";rune haavik;12345;";
    int i=0;
    String[] tmp = str.split(";");
    while(i<tmp.length)
    System.out.println(tmp);
    i++;
    Then it splits also in the "" text.
    Regards
    Rune haavik

    Rune haavik:
    The most effective way to achieve the end result is, I believe, to read the characters one by one, using a flag that indicates if we are inside quotation or not.
    Well, if we are in a mind game, then the following should do.
           String[] tmp = str.split(";(?![^\"]*\";)");

  • How to split a string with a space in between?

    Hi ABAP Guru's,
    Can you please help me out? How can I split a string into two which has a space in between?
    For example: lets suppose the string is 'LA CA USA'. How can I split this string? I have to dynamically determine the number of characters before the space therefore I cannot use number constant such as 2 or 3.
    With best regards,
    Ketan

    Hi
    Try like this
    DATA : opbal TYPE p DECIMALS 2 VALUE 0.
        SELECT * FROM zs_mkpf_mseg
                        into corresponding fields of table it_opbal
                        WHERE werks =  itmat-werks
                        AND matnr = itmat-matnr
                        AND budat = s_budat-low.
      *  sort  it_opbal by budat.
      loop at it_opbal.
    read table it_opbal.
          IF it_opbal-shkzg = 'S'.
            opbal = opbal + it_opbal-menge.
          ELSEIF it_opbal-shkzg = 'H'.
            opbal = opbal + it_opbal-menge * -1.
          ENDIF.
      endloop.
        append opbal TO itab-opbal.
      ENDFORM.                    " opbal_data
    you can also use thi s
    DATA: NAMES(30)    TYPE C VALUE 'Charly, John , Peter',
          NAMES2       TYPE STRING,
          ONE(10)      TYPE C,
          TWO(10)      TYPE C,
          THREE        TYPE STRING,
          FOUR(4)      TYPE C VALUE 'FOUR',
          DELIMITER(2) VALUE ','.
    SPLIT NAMES AT DELIMITER INTO ONE TWO.
    *     ONE contains 'Charly' and TWO contains 'John , Pet'.
    *     SY-SUBRC is 4, because TWO was not large enough to
    *     accommodate the whole of the remaining string
    SPLIT NAMES AT ',' INTO ONE TWO THREE.
    *     ONE contains 'Charly', TWO contains ' John',
    *     THREE contains ' Peter'.
    SPLIT NAMES AT ', ' INTO ONE THREE TWO.
    *     ONE contains 'Charly', THREE contains 'John',
    *     TWO contains 'Peter'.
    CONCATENATE NAMES '' INTO NAMES2 SEPARATED BY SPACE.
    SPLIT NAMES2 AT DELIMITER INTO ONE TWO THREE FOUR.
    *     ONE contains 'Charly', TWO contains 'John',
    *     THREE contains 'Peter ', FOUR is empty.
    SPLIT NAMES2 AT DELIMITER INTO ONE FOUR THREE.
    *     ONE contains 'Charly', FOUR contains 'John',
    *     THREE contains 'Peter', SY-SUBRC is 4, since
    *     FOUR was not large enough (spaces are significant
    *     characters!)
    Reward all helpfull answers
    Regards
    Pavan

  • Splitting a string with special characters

    Alrights, lets say I had a string, which will be defined as "1 + 2 + x". I want to split the string into a string array with " + " as my delimeter. How would I do so?
    String blah = "1 + 2 + x";
    String blahTwo[] = blah.split(" + ");
    System.out.println(blahTwo[0]);this would out put "1 + 2 + x" instead of "1".

    The compiler gives an error if the delimeter is called as "+" for the
    split method.Javac doesn't care but the RE compiler does. If you want to split a
    string around the '+' chacacter use "\\+", i.e. one backslash to keep
    Javac silent and the other one to keep the RE from whining.
    kind regards,
    Jos

  • Extracting part of a string with a delimiter

    Hi.  Is there a function that can take the string below, and extract EITHER everything to the left OR the right of the " | " separator?  I have many string fields with the same format and need to split them apart.  They all contain the same separator but I haven't come across anything that works.
    Thanks.
    "Communication  | 6. Invites feedback, discussion and/or suggestions about his/her own ideas and assumptions"

    Hi, 
    You can use the Split function.  This will convert your string to an array with a defined seperator like:
    StringVar myString;
    myString := "Communication | 6. Invites feedback, discussion and/or suggestions about his/her own ideas and assumptions"
    Split (myString, "|") [1];
    This will retrieve the first element in the array which is "Communication ". 
    Good luck,
    Brian

  • Separating data combined in a string with a ";" delimiter

    Post Author: debbethune
    CA Forum: General
    I have a couple fields from my file that contain data separated by a semicolon (AddOn and AddOnChg).  Field is formatted as a string.  How can I parse out the one component that has a value in order to be able to add up the values in the report? 
    InvcNum          InvcDate          AddOn             AddOnChg
    00113138        5/2/07              IFRTN;;;;          421.93;0;0;0;0

    Post Author: SKodidine
    CA Forum: General
    You can use the split function, however if you want to know which component has a value, you might have to loop through the field.  Hopefully there are set number of separators for each field.
    For example,
    stringvar x := 'IFRTN;;;;'
    split(x,';')&#91;1&#93; will give you IFRTN and split(x,';')&#91;2&#93; will give you empty field.

  • How to extract string with delimiter

    Hello all,
    I'm using Oracle 10g and want to extract string with a delimiter.
    For example, i have aaaa;;bbbb;cccc;dddd;eeee;ffff and i want to extract this string into separates strings 'aaaa', ' ', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff'.
    Thanks a lots for yours help.
    MK.

    I prefer the regular expression method myself...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'aaaa;;bbbb;cccc;dddd;eeee;ffff' as txt from dual)
      2  -- end of sample data
      3  select REGEXP_SUBSTR (txt, '[^;]+', 1, level)
      4  from t
      5* connect by level <= (select length(regexp_replace(txt,'[^;]*'))+1 from t)
    SQL> /
    REGEXP_SUBSTR(TXT,'[^;]+',1,LE
    aaaa
    bbbb
    cccc
    dddd
    eeee
    ffff
    7 rows selected.
    SQL>

  • How to split a string in LabView?

    Hello everyone,
    I'm using the LabView to control a robot named SHRIMP |||. The robot gets commands in hexadecimal format. I need to process info from the command line and therefore I want to split the string of the command line.
    In order to make myself clear this is the case: the command (in hex) is 040100 when 04 is the command itself (set velocity and steering angle), 01 is the velocity to set and 00 is the steering angle. When I read it in Labview I see - /04/01/00. I need to separate the velocity and angle from the string so I used the "search/split string" VI but it doesn't seem to help get rid of the "/" delimiter. I can get only the string before the delimiter or the string with the delimiter inside. When I tried to use offset, it seems that the LabView recognize each part of the command as one char in the string ("/04","/01","/00" are the 3 parts of the string) so I can't use it also. I tried to change the display of the string to hexadecimal format but still no luck- I couldn't convert the string to a number.
    Any ideas?
    Thanks,
    Rap Master

    RapMaster,
    What you probably want in this case is Scan From String. This takes in an input string, a formatter string similar to the ones used in C (here is a refresher if you are not familiar with printf formatters: http://www.psych.upenn.edu/~saul/parasite/man/man3​/printf.3.html), as well as some other parameters that are not as important to this project, and then outputs a number for each field that was represented by a formatter (i.e. %x). Double clicking on the VI brings up a window that will walk you through making the formatters, in case you feel more comfortable that way.
    I'm attaching a VI that does exactly what you requested, using Scan From String. To expand the functionality of this VI, just modify the formatter, and more outputs will appear for each formatter.
    David M.
    Applications Engineer
    National Instruments
    Attachments:
    ScanString.vi ‏8 KB

  • How to create a String with comma ?

    Hi All,
    I have a table with 10 records(employee name) and i have to make a string
    with comma delimiter and at the end with "."
    Can anybody tell me how to write a Java program for this ?
    Thanks in advance.

    // I believe the following example gives you the answer.
    class stringEG {
         public static void main(String args[]) {
         String emprs[] ={"1","2","3","4","5","6","7","8","9","10"};
         String vempname = "";
         for(int i=0; i<emprs.length; i++) {
         if(i == (emprs.length-1))
              vempname = vempname + emprs[i] + ".";
         else
              vempname = vempname + emprs[i] + ", ";
         System.out.println("vempname : "+vempname);
    Here dont assume that I asked you to get all the results and putting
    it into the string arrays. But its a simple example to suit your requirement.
    The half-way coding below answers your question, I hope.
    vempname = "";
    while (emprs.next()) {
    if(emprs.isLast())
    vempname = vempname + emprs.getString("empname") + ".";
    else
    vempname = vempname + emprs.getString("empname") + ", ";
    // nats.

  • Mapping issue: Split a string to multiple strings in an idoc

    Hi,
    I need to split a string with an undefined length into strings of 132 chars. The problem is, how to map from the source field to the target field,
    which belong to an idoc segment. The segment has the occurence 1 to unbounded, and the field 0 to 1. Simplifying, i need to map one source field split it in 132
    chars block and put the resultant blocks into an idoc field (maxLength = 132).
    IDoc
    Segment X
    Segment (occurence 1..unbounded)
    Field X
    Source field SourceA (undefined length)----->-----Field TargetA (occurence 0..1) (maxLength = 132)
    Segment Y

    Ok...here is one way of achiving what u want - hope ur comfortable with working with context mapping...
    Raise the context of ur source field one level higher and write  a UDF funtionto do this -
    Declare an array list
    Read the source string and append it to the arraylist.
    Then when u map ur target IDOC text...read from this array list and created ...By maintaining the context...there will be as many segments in the idocas there are in the arraylist..
    regards,
    arvind R

  • How To Split the String for "."

    Hi Friends
    I am Using Following Code to Split one String.
    String str = "Jeetendra.choudhary";
    String[] sp_str = str.split(".");
    wdComponentApi.getMessageManager.reportSuccess(str[0]);
    wdComponentApi.getMessageManager.reportSuccess(str[1]);
    but its throwing null pointer exception. 
    when i am using following code its working fine.
    String str = "Jeetendra/choudhary";
    String[] sp_str = str.split("/");
    wdComponentApi.getMessageManager.reportSuccess(str[0]);
    wdComponentApi.getMessageManager.reportSuccess(str[1]);
    what may be the issue and how to split the string with "." ?
    Thanks & Regards
    Jeetendra

    "." is a special character.
    Use
    str.split("\\.");
    Regards
    Benjamin
    Edited by: Benjamin Hansen on Dec 29, 2009 7:52 AM

  • How to split a string having string as delimiter instude of char?

    Hello Gurus,
    I want to split the string and work on each split string.
    The following code will do, but not exactly.
    It's split into morethan three strings, where coma find.
    But I want to split it using #,# as delimiter.
    Here is my code:
    //File fileData = new File("myfile.txt");
    // This will have coma separated fields data
    // while traversing this file will readLine() give the string, that is strRecord
    // BufferedReader bfrdRdrObj = new BufferedReader(new FileReader(strDataFile));
    //while ((strThisLine = bfrdRdrObj.readLine()) != null) {..........
    String strRecord = #A001#,#User1#,#this is record, so need to split and place, insert into table#;
    StringTokenizer strTknRec = new StringTokenizer(strRecord,"#,#");
    int iCounter=0;
    while(strTknRec.hasMoreTokens()){
    System.out.println(++iCoutner+"Field: "+strTknRec.nextToken());
    Please, give me hint.
    Thanks in advance.
    ~ SubbaReddy .M

    Hello Guru,
    Here "myfile.txt" CSV file.
    each line represented treated as a record and coma seperated string is treated as fields.
    But, one of the fields data may have the coma in the string itself. So, # or " (double quote) has been place before and end of the field data as a string qualifier.
    //File fileData = new File("myfile.txt");
    // This will have coma separated fields data
    // while traversing this file will readLine() give the string, that is strRecord
    // BufferedReader bfrdRdrObj = new BufferedReader(new FileReader(strDataFile));
    //while ((strThisLine = bfrdRdrObj.readLine()) != null) {..........
    String strRecord = #A001#,#User1#,#this is record, so need to split and place, insert into table#;
    StringTokenizer strTknRec = new StringTokenizer(strRecord,"#,#");
    int iCounter=0;
    while(strTknRec.hasMoreTokens()){
    System.out.println(++iCoutner+"Field: "+strTknRec.nextToken());
    And I would like to run this JRE 1.3.1
    Hope, String.split() in JRE 1.4.0 beta will some what resolve this.
    But, how to do it on JRE 1.3.1
    Please, give me hint.
    Thanks in advance.

  • How to split a string delimitted by vertical bar(|)

    Hi
    I would like to split a string delimitted by verticl bar using String.split("|") functionality. When I used split functionality for other delimitters like "-" or ":" or ";" it worked perfectly but if I use vertical bar it is splitting all the individual characters in thet string
    Is it because verical bar is having some significance in regular expressions
    Can some body please shed light on this

    joningle wrote:
    I've looked in the documentation and I don't understand why two slashes need to precede the vertical bar "|". Can you explain the reason this is the case?
    Thanks
    Jonfrom my understanding (i just taught myself this stuff in my regex lesson yesterday), the double '\ \' is to escape from the meta-character '|' , (meaning OR) ... just like if you put '\n' into a string, it's considered a newline character, if you want to denote the String "\n" you need "\ \n"
    edit: i'm being really slow today...
    Edited by: redfalconf35 on Nov 9, 2007 2:36 PM

Maybe you are looking for

  • Problem with table cell editors - Dropdown by Index, getting lead selection

    Hi experts, I have a table editor with 5 columns 1st column is a Drop Down byIndex. My contex looks like this AS_DATA(Parent Node cardinality 1.1, selection 0-1)       HEADER (NODE)       DETAILS(NODE cardinality 0..n, selection 0-1)          ACTIVIT

  • Is it possible to run process chain from the certain process/point?

    Hello Is it possible to run process chain from the certain process? How? Thanks

  • Using cache - best practice

    We created a banner using toplink. The buttons (images) are all stored in the database. The banner is in 300+ pages and they cange depending on some business rules. I want the best performance available. Yet, I want to make sure that once a record is

  • Upconvertion from labview 5.1 to 2012 - (A)

    Could anyone please upconvert this softwares from Labview 5.1 to a version which can be opened on Labview 2012? I would be really grateful. I'll have to post another codes on extra messages, as I can't attach all of them at once due to the forum limi

  • Muse Change menu color on click

    There is a muse of the day website Idea where there is an in page scrolling with menu color changes on each click event. I am using Anchor to navigaate through the page but how to get a particular menu item to change color on its click event.