38
rated 0 times
[
45]
[
7]
/ answers: 1 / hits: 130331
/ 15 Years ago, mon, march 8, 2010, 12:00:00
How can I extract 456 from xxx_456 where xxx is of indefinite length?
More From » string
How can I extract 456 from xxx_456 where xxx is of indefinite length?
var str = xxx_456;
var str_sub = str.substr(str.lastIndexOf(_)+1);
If it is not always three digits at the end (and seperated by an underscore). If the end delimiter is not always an underscore, then you could use regex:
var pat = /([0-9]{1,})$/;
var m = str.match(pat);