The last characters of a string

c:\tmp\peter
c:\tmp\test01\antonia
c:\test\olga
I would like get the following:
peter
antonia
olga
Does anybody have an idea?

what for are you replacing the beginning with a space first
and then trimming it?
SQL> with rt as
  2       (select 'c:\tmp\peter' str from dual union all
  3        select 'c:\tmp\test01\antonia' str from dual union all
  4        select 'aiyaiya' from dual union all
  5        select 'c:\test\olga' str from dual)
  6      select trim(replace(str, substr(str, 1, instr(str, '\', -1)), ' ')) str,
  7             replace(str, substr(str, 1, instr(str, '\', -1)), '') str,--just replace the beginning
  8             substr(str, instr(str, '\', -1) + 1) str--even easier
  9        from rt;
STR                   STR                   STR
peter                 peter                 peter
antonia               antonia               antonia
aiyaiya               aiyaiya               aiyaiya
olga                  olga                  olga

Similar Messages

  • How to delete the last char in a String?

    i want to delete the last char in a String, but i don't want to convert the String to a StringBuffer or an array, who knows how to do?

    Try it in this way
    String MyString = "ABCDEF";
    MyString = MyString.substring(0,MyString.length()-1);

  • How to remove only the last element of spreadsheet string

    I use path to string option to store image path into database and while retrieving the string is again converted into path but it gives out an error as the output of array to spreadsheet string gives out a tab at the end which is unable for the IMAQ read file to recognise.but when i use the path of the image directly into IMAQ readfile the image is opened . so how to remove the tab only at the end of output of the spreadsheet string(whose length can vary)? I have also attached my program with this.
    Attachments:
    retrieve_images_from_DB.vi ‏65 KB
    file_path_to_db_(images).vi ‏40 KB
    create_table_for_images.vi ‏45 KB

    indhu wrote:
    > Thanks for your reply!
    > But my problem is to remove only the last element(which is a tab or an
    > alphabet) from a spreadsheet string of any length.
    If you just want to remove the last character of a string just use the
    String Size function reduce the result by one and wire it together with
    the string to the Split String function.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Deleting the last char of a string

    How can I Delete the last char of a string???
    example:
    asd@fdg@vvdfgfd@gdgdfgfd@gdfgdf@
    I want delete the last @!
    Tks in advance!

    hi,
    try this:
    lv_count = strlen(string).
    lv_count_last = lv-count - 1.
    replace string+lv_count_last(lv_count) in string by ' '.
    This should work.
    thnx,
    ags.
    Edited by: Agasti Kale on Jun 4, 2008 9:03 PM

  • To extract the last word in a string

    Hi
    I am using BODS 14.1.1.210 
    I would like to extract the last word in a string in BODS query. How can I achieve this when  I don't know how many words are present in a space delimited string.
    Example
    Input                                              Output    
    My name is Tim                              Tim
    Complicated                                    Complicated
    there is a bird in the nest                 nest
    Please let me know if there is a query function for this one.
    Cheers!

    Hi,
    try this-
    word_ext(fieldname,-1,' ')
    Atun

  • How we can find the last character in a string(Urgent Plz!)

    Gurus!
    How we can find the last character in a string.
    e.g i have a string say "Str" with value "10-01".
    Now i want to find the last character in "Str" i.e "ONE=1".
    i am using Oracle developer 6i with Oracle 8i(1.7).
    Plz help!
    Many thanks!

    Use the substr() and length() functions -
    x := '10-01';
    y := substr(x, length(x));

  • Looking for the last item in a string set in a particular character style

    I should find each space that is the last character in a string set in a particular character style. For example, in the passage "123 456 789" (the underlined part here indicating a passage set in a particular character style), my ideal GREP search would yield a match after the digit 6.
    How do this?

    Excellent! This works perfectly. I have used your string with the bold character formatting, and replaced the matches with [nothing], set in None style.
    On second thought, I was surprised that it indeed had worked: why was the space replaced, and not deleted? Shouldn't I have used
    (?<!.)(\s)(?=\w)
    and replaced it with
    $2

  • Testing the last character of a string using .endsWith

    Hi,
    I want to check to see if the last character of a string is '@'.
    I tried if (StringAt.endsWith("a")) {
    but got no results.
    Is this the correct way to do it or is there another way.
    Thanks.
    Adam

    javadocs:
    String's endsWith method takes a string argument.
    endsWith
         public boolean endsWith(String suffix)
              Tests if this string ends with the specified suffix.
              Parameters:
                   suffix - the suffix.
              Returns:
                   true if the character sequence represented by the argument is a suffix of the character sequence
                   represented by this object; false otherwise. Note that the result will be true if the argument is the
                   empty string or is equal to this String object as determined by the equals(Object) method.
              Throws:
                   NullPointerException - if suffix is null.

  • The last character of a string

    How to judge the last char of a string is " ?
    if (s.endsWith("""))or
    if (s.endsWith("/""))

    bet
    you just copied and pasted what the OP had written
    and quickly put that
    backslash in, hit post without previewing first just
    to make me look like
    a slow old sod! It's not fair ;-)
    kind regards,
    JosNope, I used the Alt-[numeric code] combinations to manually type each character. Cut-n-paste is for wimps, and actually typing single-stroke keys is for milquetoasts.
    Alt-[numeric code] is for real men ;-)

  • How to select the last elements in a string

    Hi Guys
    I am using UART RS232 protocol and i need to calculate the check sum. My data came in decimal and in the end it must be doubles to manipulate it. So my problem is, for example, the sum of all elemants is in decimal 1742 and in hex is 6CE and i wont only the last two elemants, CE that corresponds to 206 that is the result of my checksum. Can anyone help me? 
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    String last elements.vi ‏9 KB

    Thanks Syrpimp
    My data came from HMI in decimal like the example that i show above. Each cell is a value. You used an array, but i think that i can't use it because it must be done automatically and the data field have variable length. 
    The UART protocol frame has a start frame field that corresponds to two ‘{‘ characters and an end frame field that corresponds to two ‘}’. Additionally, besides the data field, that has variable length, it has a byte that corresponds to the command type and another that is the checksum. The following table illustrates the protocol.
    Bytes considered in checksum
    Command Data
    Start Frame
    Cmd
    (hex)
    Data0
    Data1
    Data2
    Data3
    Data4
    Data5
    Data6
    Data…
    CHK SUM
    End Frame
    1 Byte CHK SUM (sum of all data bytes truncated to 1 byte)
    Fig. 1 UART communication protocol template
    I receive data like this:
    123
    123
    160
    54
    111
    103
    110
    108
    107
    109
    108
    108
    100
    100
    100
    100
    0
    0
    1
    4
    5
    0
    0
    0
    0
    0
    0
    7
    96
    1
    0
    0
    0
    0
    0
    10
    51
    1
    0
    0
    51
    1
    1
    23
    12
    0
    206
    125
    125
    I'm trying explain my doubt the best way i can and i thank you all.

  • Search for the last delimiter in a string

    Hi all,
    My requirement is whenever my length of the string reach 50 characters, the program will search for the last comma delimiter and break line into 2 lines.
    The string format is like this: -
    Input: -
    1234567890123456789012345678901234567890,1234567890
    Expected output: -
    1234567890123456789012345678901234567890,
    1234567890
    Input: -
    1234567890,1234567890,1234567890,1234567890,1234567890
    Expected output: -
    1234567890,1234567890,1234567890,1234567890,
    1234567890
    The difficult part for me is how to search for the last comma delimiter when it reached 50 characters?
      IF strlen(gv_fetxt) > 50.
      .... " do something to break the line into two lines. 
      ENDIF.
    Please help and guide me.
    Thanks in advance.

    Hi,
    Test the following Sample Code it is working according to your Requirements.
    DATA: str1(200),
          str2(200),
          str3(200),
          main_str_len TYPE i,
          sub_str_len TYPE i,
          off_start TYPE i,
          off_end TYPE i.
    DATA: BEGIN OF it_str OCCURS 100,
      str(200),
      END OF it_str.
    str1 = '1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890'.
    main_str_len = STRLEN( str1 ).
    off_start = 0.
    off_end = 50.
    WHILE main_str_len GE 0.
      IF main_str_len GT 50.
        CALL FUNCTION 'STRING_REVERSE'
          EXPORTING
            string    = str1+off_start(off_end)
            lang      = 'E'
          IMPORTING
            rstring   = str1+off_start(off_end)
          EXCEPTIONS
            too_small = 1
            OTHERS    = 2.
        REPLACE FIRST OCCURRENCE OF ',' IN str1 WITH '$'.
        CALL FUNCTION 'STRING_REVERSE'
          EXPORTING
            string  = str1+off_start(off_end)
            lang    = 'E'
          IMPORTING
            rstring = str1+off_start(off_end).
        SPLIT: str1 AT '$' INTO str2 str3.
        it_str-str = str2.
        APPEND it_str.
        str1 = str3.
        sub_str_len = STRLEN( str2 ).
      ENDIF.
      IF main_str_len LT 50.
        it_str-str = str1.
        APPEND it_str.
        main_str_len = -1.
      ELSE.
        SUBTRACT: sub_str_len FROM main_str_len.
      ENDIF.
    ENDWHILE.
    LOOP AT it_str.
      WRITE: it_str-str.
    ENDLOOP.
    Please Reply if any Issue,
    Best Regards,
    Faisal

  • Want to single out the last character of a string

    There is a field where there are many strings of varying length. E.g.: AB001XUV, AB003XUK, DJ8933FXUV etc.
    From these strings I need to create a virtual column where only the last character is shown. So it shall be V, K, V for values from the above example.
    Can anyone please suggest me how to achieve this.
    Regards
    Hawker

    SQL> with t as (
      2  select 'AB001XUV' col from dual
      3  union
      4  select 'AB003XUK' col from dual
      5  union
      6  select 'DJ8933FXUV' col from dual
      7  )
      8  select substr(col,-1,1) from t
      9  /
    S
    V
    K
    V
    SQL> create table temp(id number,
                      col varchar2(10),
                      VIRTUAL_COL VARCHAR2(1)   GENERATED ALWAYS AS (substr(col,-1,1)) VIRTUAL
    SQL> insert into temp(id,col) values(1, 'AB001XUV') ;
    SQL> select * from temp ;
            ID COL        V
             1 AB001XUV   V
    SQL> Edited by: Azhar Husain on Aug 16, 2011 1:17 PM

  • Any easier way to replace the last character of a string?

    this is what I got:
    select SUBSTR('tjgb005dy_01_31_08',1,LENGTH('tjgb005dy_01_31_08')-1)||'1' from dual;
    tjgb005dy_01_31_01and I am not quite fond of it. it looks ugly and it is long.
    so, I wonder if you guys have better ideas?
    Thanks

    (Perhaps with replace there is no easier solution than the primary posted.)Well, look where I ended up...
    SQL> -- generating sample data:
    SQL> with t as ( select 'tjgb005dy_01_31_08' str from dual union
      2              select 'tjgb005dy_01_31_03' from dual union
      3              select '888888888888888888' from dual
      4            )
      5  --
      6  -- actual query
      7  --
      8  select str
      9  ,      case
    10           when substr(str, -1) = 8
    11           then
    12             substr(str, 1, length(str)-1)||'1'
    13           else
    14             str
    15         end
    16  from t;
    STR                CASEWHENSUBSTR(STR,-1)=8THENSU
    888888888888888888 888888888888888881
    tjgb005dy_01_31_03 tjgb005dy_01_31_03
    tjgb005dy_01_31_08 tjgb005dy_01_31_01Now I'm going to stay at the coffee-machine for the rest of the day... ;)

  • Order by on the basis of last characters of the column

    hi
    i have this type of data in Column
    ABL - Allied Corp. services (XES) - Newyork
    ABL - Allied Corp. services (XES) - Chicago
    SBS - Logistics - Newyork
    ETC..
    As the last characters are for city and i want to perform order by on the basis of city.The naming convention is "the name always contain two hiphens(-)
    and the city name in the last".(means after second '-')
    Regards

    SQL> INSERT INTO dt_test VALUES('ABL - Allied Corp. services (XES) - Newyork');
    1 row created.
    SQL> INSERT INTO dt_test VALUES('ABL - Allied Corp. services (XES) - Chicago');
    1 row created.
    SQL> INSERT INTO dt_test VALUES('SBS - Logistics - Newyork');
    1 row created.
    SQL>
    SQL> select
    2 column_1
    3 FROM
    4 dt_test
    5 ORDER BY
    6 SUBSTR(column_1, INSTR(column_1,'-',1,2) + 2);
    COLUMN_1
    ABL - Allied Corp. services (XES) - Chicago
    ABL - Allied Corp. services (XES) - Newyork
    SBS - Logistics - Newyork

  • Instr to pick up anything before the last dot

    This is on oracle 10.2.0.3 on unix using sqlplus
    I am trying to write a select statement that picks up anything after the first - (dash) symbol and before the last . (dot) in a string.
    I got the first part right -- to pick up anything after the first dash
    SELECT SUBSTR('P3834_MD-1.14.script', INSTR('P3834_MD-1.14.script','.' )-1)
    FROM dual;
    1.14.script
    How do I further string this down so that it retrieves me everything that is before the last . (dot) which is 1.14
    I may have several dots, for example 1.1.33.4.script . I still need 1.1.33.4

    Hi,
    In Oracle 10 (and up) that kind of thing is much easier using regular expressions.
    To find everything from the first '-' through the last '.' in a string s:
    REGEXP_SUBSTR ( s
                  , '-'         -- hyphen
                    || '.*'     -- 0 or more characters (period matches anything)
                    || '\.'     -- period (escaped because period has special meaning)
                  )Using INSTR, you can give -1 as the third argument to tell INSTR to search backwards from the end of the string:
    INSTR ( s
          , -1
          )

Maybe you are looking for