-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
  • 2
    string.match(/\d+/g) Commented May 5, 2017 at 11:18

1 Answer 1

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]
Sign up to request clarification or add additional context in comments.

3 Comments

Hey @jonathandion, I need 30, not 3 and 0 separately.
I updated my answer.
If the answer is good you should accept it to close the question. Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.