I have a string like "D-30-25-4", then I want 30 and 25 as the desired result
I have tried this
value = "D-30-25-4";
value1= parseInt(value.substring(5,7)); // 25
value12 = parseInt(value.substring(2,4)); //30
but it fails when value is "D-30-100-4";
"D-30-25-4".split('-')[1]and"D-30-25-4".split('-')[2]should give you the resultvar parts = value.split("-"); console.log(+parts[1],+parts[2]);