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:
var rest = "abcdef".substr(start, length);
You also can read more about this function here: http://www.w3schools.com/jsref/jsref_substr.asp
The following will reproduce it.
"abcdef".substr(-1);
"abcdef".substr(-2);
"abcdef".substr(-3, 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With