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

Similar Messages

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

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

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

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

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

  • 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

  • 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

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

  • Select last character of a string

    Hello,
    I would like to select the last character of an address string. For example, in '165 John Ave W' -- select result 'W'. I tried to use RIGHT but it doesn't work. I'm using SQL Plus.
    SELECT RIGHT(ADDRESS,1) FROM addresses;
    ORA-00904: "RIGHT": invalid identifier
    I can't find the appropriate select statement to achieve the result I want. Ideas?
    Thanks!

    The SUBSTR function can take a negative start parameter, which counts in from the end of the string
    http://www.techonthenet.com/oracle/functions/substr.php - that should get you going, let me know if you get stuck.
    Carl

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

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

  • 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

  • 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

  • Checking last character

    What would you consider being the best way to check the last character of a string?
    var folderPath = '~/Desktop/Test';
    if (folderPath[folderPath.length - 1] !== '/') { folderPath += '/'; }
      or
    if (folderPath.slice(-1) !== '/') { folderPath += '/'; }
    I see that changePath() can also be used to keep track of this path separator.
    Thanks.

    Hi Hans,
    I was trying to come up with a function to move a folder and it's contents, or a file... similar to how the OS X Finder would do it.  However, I just noticed when the files are copied over, they're not the same file size as the original which makes me think it's stripping resource forks, etc.  :-(
    I'm looking now at using doScript and running ditto from the command-line with applescript.  Here's the code I was working with earlier though:
    function moveItem(oldPath, newPath) {
        newPath = newPath.toString();
        //if (newPath[newPath.length - 1] !== '/') { newPath += '/'; }
        if (newPath.slice(-1) !== '/') { newPath += '/'; }
        var oldPathType = oldPath.constructor.name;
        if (oldPathType === 'Folder') {
            newPath += (oldPath.name + '/');
            with (Folder(newPath)) {
                if (! exists) { create(); }
            for each (var i in oldPath.getFiles()) {
                if (i.constructor.name === 'Folder') {
                    moveItem(i, newPath);
                } else {
                    i.copy(newPath + i.name);
                    i.remove();
            oldPath.remove();
        } else if (oldPathType === 'File') {
            oldPath.copy(newPath + oldPath.name);
            oldPath.remove();
        } else {
            throw 'Problem moving file/folder!';

Maybe you are looking for

  • Sub-reports DO NOT WORK in Crystal for Eclipse v2

    Hi,<br /> <br /> We have recently upgraded from Crystal JRC to CR4E 12.2.202. Our application updates the JDBC connections at runtime to supply credentials.<br /> <br /> Everything seems to be working except sub reports.  When using sub reports we ge

  • Ipod Touch does not restore

    When i connected my itouch in the computer to charge it, it said that it needed to be restored and when I try to restore it, it says extracting software and after that it says verifying restoring.. and then the unknown error 3014 occurred message pop

  • Sign in button not working in folio builder panel

    sign in button not working in folio builder panel, how i can fix it ? cs 6 on mac 15" os x mavericks, the rest are working thanks

  • Batch management number range issue

    Hello Experts, We have one requirement like this we are following Batch unique at material level. Client requirement is like this; they require separate number range for plant and order type combination. Is it possible? If it is possible please speci

  • Regarding MD01 MRP Run

    Dear SAP Gurus, The issue is PR is getting created for engineering during the MRP run of either  Production / Materials. MRP controller for Production is 001 &  material is 003 where as MRP controller for Engg. is 004, and we are not running any MRP