Requirement:

Need to get last 5 characters of a string.

My Thoughts:

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 :P

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

Solution:

Wrote a small 3 line script :D 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.

OkAvarageGoodVery GoodExcellent (3 votes, average: 3.33 out of 5)
Loading ... Loading ...