Sunday, September 25, 2011

Find last few characters from a string

Below is the code that uses substr() function that will return the last three characters from the string. You can change that -3 and 3 parameters according to your need.

First param -3 means start from index 3 from last. And second param 3 means the three characters.


<html><body>

<script type="text/javascript">
var string = "Test String";
string = string.substr(-3, 3);
document.write(string);
</script>

</body></html>


Pretty simple code...

No comments:

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...