JS - Method to Extract numbers from given string

by barkkathulla 2014-03-01 14:57:52

Easy way to get numbers from given string variable:


var matches = yourstringvariable.match(/(d+)sl(d+)/);
var number1 = Number(matches[1]);
var number2 = Number(matches[2]);


(or)


(your_js_variable.match(/d+$/)[0]);
971
like
0
dislike
0
mail
flag

You must LOGIN to add comments