Quote:
Originally Posted by 123jo
Anyone has an idea of how I can get the last integer of a string? Parsing doesn't seem to work...
|
<script type = "text/javascript">
Code:
var str = "1234a56d";
str = str.replace(/[^\d]/gi,"");
var len = str.length;
var x = str.charAt(len-1);
alert (x);
var str = "14x10+2x1123";
var x = str.match(/\d+\D*/gi);
var len = x.length;
var y = Number(x[len-1].replace(/[^\d]/g,""));
alert (y);
</script>