-1

Here is a string: (1 AND 2) OR 30 AND (4 AND 5). I need a list of numbers included in this string. Please help me out.

1 Answers1

0

Use match:

var numbers = "(1 AND 2) OR 30 AND (4 AND 5)"
var formatted = numbers.match(/\d+/g)
console.log(formatted); // [1,2,30,4,5]
Jonathan Dion
  • 1,651
  • 11
  • 16