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

Similar Messages

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

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

  • WHAT IS THE BEST NAD EASIER WAY TO REPLACE THE SKY IN A LANDSCAPE FOR A DIFFERENT ONE?

    WHAT IS THE BEST AND EASIER WAY TO REPLACE A SKY IN A LANDSCAPE FOR A DIFFERENT ONE?

    depends who clunk you can get away with.
    easiest is magic wand and use the layer properties to make it 'multiply' or 'lighten' or 'darken' etc as suits your images.
    a step on from this would be to use the layer blending options. it's the easiest way to get a good overlay,
    paste the new sky image into your image and scale it to fill the whole area, then double click the layer
    then use the blending options especially noting the 'blend if' sliders at the bottom which you can use to tell it to allow different tones to show through.
    this mixed with holding the l'alt' key as you adjust the sliders allows you to fade from 0-100% of certain tones being visible through the layers, so you can for example allow you new sky layer to be seen in between branches of a tree etc. fiddle with it and you'll see what it does.
    combine this with a layer mask where you can paint out bits that you definitely don't want the sky to show through.

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

  • Is there any easy way to move the cursor in a plot by just a mouse click?

    Right now I have to click at the cursor and drag it to the right position. I was wondering if there is an easy way to just do the mouse click to change the cursor (not dragging the cursor). I have only one cursor in the graph.

    Assuming that if you click the cursor that you want it to always move to the same position, I think that you could do what you want by calling the cursor's SetPosition method in the graph's CursorMouseDown event.
    - Elton

  • Replace the first character in a String with blank

    String a = dgramRsp.getAddress().toString();
    a = a.replace('/','');The problem with the first statement is that it returns an ip address with a '/' in front of it. Like so.../192.168.0.190
    I need to get rid of the '/'. The replace won't work because it wants a character between the ' '. Thanks for your time.

    I had to think about it for a sec but yes you're
    right.
    InetAddress a = dgramRsp.getAddress();
    String b = a.getHostAddress();
    substring(1) would have worked, too, but it would have been redundant (removing a previously added slash).

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

  • Easy way to replace images?

    Hi, I am using Pages 09 for a document with some diagrams and different images that I have. I have sized them the way I want. My problem is that I have updated some of these images, changed some colors, text etc in the images, but they are the same size and the same filename. Is there any easy way to replace these old images with the new updated version? Is there some way to re-link them as you can in InDesign?
    I tried to just copy an image from Finder, then selecting the old image and pasting, hoping that the size would be adjusted but it did not: the new image was huuuge.
    Thanks!

    As far as I remember, just replace the old files by the new ones in the document's file.
    If it is a flat file, rename it
    xxx.pages.zip
    double clic to expand it
    Now, in both original format you have now a package.
    ctrl click its icin > Show Package Contents.
    After that, you will see the picture files.
    For safe, move the old ones in a folder.
    Move the new ones in the package.
    Close the package
    Double click to open it.
    It all worked fine you will see the new pictures.
    Maybe one day I will write a script to automate the task.
    Yvan KOENIG (from FRANCE samedi 21 mars 2009 21:33:11)

  • Is there an easy way to replace fonts in Photoshop ?

    Is there an easy way to replace fonts in Photoshop without clicking on each text layer? We just got a new font system, so now our fonts don't match up. Looking for a fast/easy way to replace the fonts like in InDesign or Illustrator.

    Actually (You probably can guess what I’m driving at) Scripting could be used to automate such a task, but it would not really be »easy« unless one has some experience in the matter – if text-items contain a mixture of fonts it might even get kind of »complicated«.
    Still, depending on the quantity of files to be edited, the OP could try asking in the Scripting Forum if someone might not have a Script for something like this already …

  • Any easy way to set *.jars classpath in windows

    Is any easy way to set the classpath for serveral jars in windows?
    for example, if I have 1000 jars in a folder "C:/MyJar", is this the only way to set the classpath with:
    CLASSPATH=C:/MyJar/Jar0001.jar; C:/MyJar/Jar0002.jar; C:/MyJar/Jar0003.jar; .........; C:/MyJar/Jar1000.jar
    ?

    Is any easy way to set the classpath for serveral jars
    in windows?
    for example, if I have 1000 jars in a folder
    "C:/MyJar", is this the only way to set the classpath
    with:
    CLASSPATH=C:/MyJar/Jar0001.jar; C:/MyJar/Jar0002.jar;
    C:/MyJar/Jar0003.jar; .........; C:/MyJar/Jar1000.jar
    ?You shouldn't have a system CLASSPATH environment variable.
    You don't add every JAR for every project to a system CLASSPATH. You should be doing it on a project-by-project basis, preferrably with a script or an Ant build.xml.
    Doing it with a system environment variable makes your apps less portable, because now you depend on the target machine being set up in a particular way. You should figure out how to package your apps appropriately so clients don't have to worry about that setup issue.

  • 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

  • Accidentally overwrote all album artwork - any easy way to restore???

    I accidentally reset all of my itunes songs album art to a single album image. Aargh! Needless to say, big mistake. Is there any easy way to recover the original art, or is it gone forever??
    Laura.

    How did you do that? You might try Fetch Art. From the Read Me:HOW TO USE IT:
    In iTunes, select one or more songs, or select a playlist, then choose "Fetch Art" from the iTunes Script menu. The Fetch Art application will start, and attempt to download art for the songs you chose. After art downloading has finished, select one or more of the songs to see what art was found. If you are happy with the art that was found, hit Return to copy the art to iTunes.
    You can also copy art to iTunes for every song in the list by choosing "Fetch Art" > "Copy All Art to iTunes," or by hitting command-T. This may take awhile if there are many songs in the list.

  • 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