Possible Duplicate:
javascript substring
How can I do substr (php) in JS?
Example code from PHP:
<?php
$rest = substr("abcdef", -1); // returns "f"
$rest = substr("abcdef", -2); // returns "ef"
$rest = substr("abcdef", -3, 1); // returns "d"
?>
It is very similar to PHP:
You also can read more about this function here: http://www.w3schools.com/jsref/jsref_substr.asp