[Solved] How to get numbers out of string into array [duplicate]
You can use String#match with a RegExp. You can use Array#map afterwards to convert the strings to numbers if needed. var str=”156p1m2s33c”; var numbers = str.match(/\d+/g); console.log(numbers); What’s wrong in your code: cust_code and url are not part of the function. Refer to str. You declare prodId twice. You don’t handle the number between “s” … Read more