How to delete last character in a string

Guys i have a question...
how can i delete the last character in a string..
for example
String myString = "helloWorld, ";
how do i delete the last character in this string which is a "," ?

String newString = myString.substring(0, myString.length()-1);

Similar Messages

  • Deleting last character of a string

    Hi Abapers,
    I want to delete the last character of my workarea and then store into table.
    The workarea says that it is FAX|
    I have to remove the last character.
    How to do tht.
    Please reply.
    Thanks

    hi
    do this in following way
    frist find the String length
    let it will be
    w_str = 'sdn is wonderfull'
    now use.
    w_len = strlen(w_str) .
    now
    w_result = w_str+0(w_len - 1).
    Cheers
    Snehi

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

  • LAST CHARACTER OF A STRING

    Hi Gurus,
    I want to get the last character of a String.For Ex.
    I have name = 'ZXCDFG":?'
    And I want to print the last character ?.
    How can i do it.
    Thanks in Advance.

    Hi Pradeep,
    Just find the String Length and use the offset commands
    DATA : DATA TYPE CHAR20 'ABCDEFG',
    DATA : DATA1,
    DATA : LEN TYPE I.
    LEN = STRLEN( DATA ).
    LEN = LEN - 1.
    DATA1 = DATA+LEN(1).
    Regards
    Kumar M.

  • How to replace a character in a string with blank space.

    Hi,
    How to replace a character in a string with blank space.
    Note:
    I have to change string  CL_DS_1===========CM01 to CL_DS_1               CM01.
    i.e) I have to replace '=' with ' '.
    I have already tried with <b>REPLACE ALL OCCURRENCES OF '=' IN temp_fill_string WITH ' '</b>
    Its not working.

    Hi,
    Try with this..
    call method textedit- >replace_all
      exporting
        case_sensitive_mode = case_sensitive_mode
        replace_string = replace_string
        search_string = search_string
        whole_word_mode = whole_word_mode
      changing
        counter = counter
      exceptions
        error_cntl_call_method = 1
        invalid_parameter = 2.
    <b>Parameters</b>      <b> Description</b>    <b> Possible values</b>
    case_sensitive_mode    Upper-/lowercase       false Do not observe (default value)
                                                                       true  Observe
    replace_string                Text to replace the 
                                         occurrences of
                                         SEARCH_STRING
    search_string                 Text to be replaced
    whole_word_mode          Only replace whole words   false Find whole words and                                                                               
    parts of words (default                                                                               
    value)
                                                                               true  Only find whole words
    counter                         Return value specifying how
                                        many times the search string
                                        was replaced
    Regards,
      Jayaram...

  • Truncating last character in a string

    I am making a dialpad. It is just for display so I am using a
    string for the numbers selected. I am trying to make a back button
    that would clear the last number added. I tried mystring.length-1
    but that doesn't seem to be doing the trick. Is there a simple way
    to truncate the last character in a string, of variable
    length??

    Here's an example
    var someStr="asdfasdf saf asdf sadfas dfs fsa asf";
    while (someStr.length) {
    someStr = someStr.substring(0,someStr.length-1)
    trace(someStr);
    }

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

  • To delete first and last character of a string???

    Hi Everybody !!!
    Do you know a method that can permit to delete in a string the first and the last character?
    For instance I have in my string this word : [the word]
    I would like to delete the '[' and the ']' character.
    Is exist a method that permit to delete this character?
    Thanks !!!

    Look at the substring method of the String class.
    Note that since string is immutable, you'll need to assign the results of substring to a variable (could be the same as the original or different).

  • Deleting last char in a string...

    I have a string that is created as follows: strBuffer += k.getKeyChar();(k is KeyPressed ...KeyEvent) How can I delete the last Char in the string strBuffer?

    Hi
    // simply substring
    if (strBuffer.length() > 1)
        strBuffer = strBuffer.substring(0, strBuffer.length()-1);
    // you may also use
    if (strBuffer.length() > 1)
        StringBuffer buffer = new StringBuffer(strBuffer).
                                   deleteCharAt(strBuffer.length()-1);
        strBuffer = buffer.toString();
    }I've not tested the above code myself & I've written the above code on the go after reading your query. The above code definitely work & help you.
    Regards,
    JPassion

  • 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

  • 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 get each character in a string

    as in 'C' we use arrays to get each character of a string stored in array.how can we get each character of a string stored in a variable.

    Hi,
    For that you need to do offset.
    for example one variable called VAR contains string 'HUMERAH'.
    if you want each character of that string then you need to decalre as many variable as the number of string.
    like
    data : var1(1),
             var2(1),
    var(3),
    var(4).
    var1 = var+(1).
    var2 = var+1(1).
    var3 = var+2(1).
    var4 = var+3(1).
    now var1,var2,var3,var4. contains the single characters.
    Regards,
    Guru
    mark helpful answers

  • How to delete a character at the end of each line in a file

    Hi
    How to remove a character or symbol at the end of each line in a file?
    I am having a file with every end of line conatins special chars @.
    I need to remove or delete that sysmbol from file.
    Regards

    JoeBorland wrote:
    File is large about above 20,000 lines.
    I need to find the optimum solution.
    Like reading a file and find the end of character and writing into a file.
    The above way is correct or any other way?Try it and see. Such a program will only be a dozen lines long.

  • How to delete last user session from backend SQL query?

    Sometimes user session gets closed between some work by any reason.
    When next time that user logs to P6, he gets some error or particular functionaly dosen't work for that user or system hangs.
    In that case if i decided to clear last session history of that user from database, how to write SQL query?
    I don't want to delete all user sessions from table USESSION and USESSAUD, i simply want to delete last user session of particular user (E.g XYZ).

    I am quoting this from MOS Doc Id "Why would multiple session records be present in the User Sessions screen in P6 Web, and why might some of them have different IP addresses? (Doc ID 1600172.1)"
    Multiple sessions show up for users since different sections of P6 Web have their own sessions associated with them. If a user is authorized to use multiple areas of the software they will have multiple sessions each time they log in. Additionally, if users are closing their browsers before logging out of P6 Web Access you might see some past sessions still appearing in the list. These will eventually be cleared out by background jobs, however you can also reset the sessions in the software by clicking the "Reset User" link (Administer > User Sessions > Manage User Sessions), or by choosing the "Reset All Users" link (Administer > User Sessions > Manage User Sessions) to do this for all past sessions.
    Multiple IP addresses for sessions can happen when a user logs in from different machines. For example, a person may login at their desk, but then go to a colleagues workstation to discuss a project, and log in from there. Doing so will leave them with multiple IP addresses in the session records.
    Hope this helps
    Regards,
    Sachin Gupta

  • Removing last character of a string

    Hi Gurus,
                 Is there any way to remove the last character of staring other that finding the string length and doing it?
    waiting for reply
    Ravi

    HI,
    yaa u can do this by one logic
    wht u do is concatenate one special symbol like $ to the string wht u have and in the next statement by using tht special symbol u can find fdpos i.e. field postion i.e. at which lenght it is there and then in again another statement u can increa fdpos by one and u can cut the string at tht length
    i think u got my logic
    further if u have any quiries u can contact me on [email protected]
    plzz reward if it is usefull....

Maybe you are looking for