Searching for the last character in a string

First I want to thank you for your tip and tricks. In your answer on the above topic you search the starting position of the number like this:
string_location:=MIN(DECODE(INSTR(my_string,'0'),0,999,INSTR
(my_string,'0')),DECODE(INSTR(my_string,'1'),0,999,INSTR(my_string
('1')),....,DECODE(INSTR(my_string,'9'),0,999,INSTR(my_string,'9')));
Another possibility would be:
string_location:=INSTR(TRANSLATE(UPPER(my_string),   
'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ',    
'NNNNNNNNNAAAAAAAAAAAAAAAAAAAAAAAAA'),
'A',-1);
Like this you get the last character in the string. What do you think about it?

    Requires Free Membership to View

I think it is great!!! But shouldn't the INSTR function be looking for 'N' instead? Just a minor detail.

There seems to always be more than one way to get the job done these days. And one persons resolution may not always be the best. I never would have thought about using the TRANSLATE function for solving this problem. But now I probably won't overlook it in the future!

For More Information


This was first published in May 2002

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.