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

187
Views
(javascript) If you had a string that was a word with a number at the end. How would you add a space between the word and the number?

For example:

let word = 'Winter4000'

const seperate = (word) => {
  ...
}

seperate(word) // output: Winter 4000

The word can be random and the number is always at the end.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Ian's answer works for most integers, but for decimals or numbers with commas (like 1,000,000), you'll want an expression like

word.split(/([0-9.,]+)/).join(" ");

so it doesn't put an extra space when it runs into a decimal point or comma.

Writing this as a function,

let word = 'Winter4,000.000';

const seperate = (input_word) => {
    return input_word.split(/([0-9.,]+)/).join(" ");
}

console.log(seperate(word));
about 4 years ago · Juan Pablo Isaza Report

0

let word = 'Winter4000'
const seperate = word.split(/([0-9]+)/).join(" ")

split it using regex pattern looking for numbers, then join it back together with a space added

about 4 years ago · Juan Pablo Isaza Report

0

const word = 'Winter4000';
const result = word.match(/[^\d]+/) + ' ' + word.match(/[\d]+/);
about 4 years ago · Juan Pablo Isaza 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!