|
Here is a function getlastintstring which would return the last integer string from a string passed
as paramter.
here is an example
input:
Hello 100worldthis2000is a test.
output:
this would return 2000
function getlastintstring(str) {
var bnumeric = 0;
var strlength = str.length;
var numstr = "";
for (strlength = strlength; strlength > 0; strlength--) {
if (IsNumeric(str.substring(strlength, strlength + 1))) {
numstr = str.substring(strlength, strlength + 1) + numstr;
bnumeric = 1;
} else {
if (bnumeric > 0) {
return numstr;
}
}
}
return numstr;
}
|