07-08-2015 09:22 AM
Can someone help in the extracting last three characters of a string...irrespective of the length of the string i should extract last 3 three into new variable......I am attaching the sample number
output should like this.....
Thanks in advance
07-08-2015 09:35 AM
Not sure if you want the last 3 in character or numeric, but this should pull out the last 3 regardless of the length of the variable:
Hope that helps!
07-08-2015 10:03 AM
It means that
length(var)-2 this means from the length of the variable you are going 2 places prior.
for ex: 32-015-10101
length (var)= 12
length(var)-2=10 from 10th position you want to take three characters, which will give you the last 3 chars that is why its -2
07-08-2015 10:05 AM
if the lenght of the var is 10 then we have to take the characters from 8,9 and 10th position.
substr(var, starting position, no of characters)
to get the starting position we will do length(var) - 2
if you want the last 5 characters then the same will be length(var)-4
07-08-2015 10:13 AM
If you use reverse function then the entire string will be reversed.
if you take the first 3 characters from the result then we will get the result which is reverse to the actual req output
the result will be like
but he wants the result like
So again we have to apply reverse for the final output to get the desired output
Need further help from the community? Please ask a new question.