Need to get last 5 characters of a string.
Sounds a simple requirement but the place from where I read this requirement had mentions of assigning it to buffer and the finding out the size 😛
When I thought about this requirement the first thing that came to my mind is that it is possible to do this with the help of substring function
Wrote a small 3 line script 😀 given below and was able to fulfill the requirement.
var teststr = “sdfsdfsdfsfjksdhfdsflskdf12345”;
var len = teststr.length;
var subs = teststr.substring(len-5);
But then I said to myself is there any other way to do it through configuration or something but was not able to find anything. If you guys know anything that I don’t please let us all know.
Waiting for you comments.