Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

316
Views
How to get numbers separated by any delimiter (space or any non numeric character)

How to get numbers separated by any delimiter (space or any non numeric character).

I tried Input string: "111,256 323| 78987 & 6543".split(/,| /),

but then it requires me to specify the delimiter. What Regex can I use to split the numbers and get like [111, 256, 323, 78987, 6543]

almost 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can try this :

let numberPattern = /\d+/g;
let numbersArr = "111,256 323| 78987 & 6543".match(numberPattern)
console.log(numbersArr)

The result must be like that : click here

almost 4 years ago · Santiago Trujillo Report

0

To split by non numeric characters:

"111,256 323| 78987 & 6543".split(/[^\d]+/)

If you want to keep decimals:

"111,256 323| 78987 & 6543".split(/[^0-9.]+/)

If on top of that you want to get an array of numbers, map the strings to numbers:

"111,256 323| 78987 & 6543".split(/[^\d]+/).map(n => Number(n))
almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!