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

273
Views
How to replace the break with a comma after two words?

I use the following line of code to replace all spaces with commas between words.

SET keyword-virgula EVAL("var spatiu=\"{{Keyword}}\"; spatiu.replace(/ /g,','); ")

How could I make the comma be added after two words?

word word, word word, word word, word word, word word,

Can someone help me? thanks

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

0

You can match 2 times one or more non whitespace characters followed by 1+ whitespace character in between using a pattern.

In the replacement use the full match using $& followed by a comma.

const s = "word word word word word word word word word word";
const regex = /\S+\s+\S+/g
console.log(s.replace(regex, "$&,"));

about 4 years ago · Juan Pablo Isaza Report

0

With JS we can achieve , i hv no idea in Regex

var str  = "word word word word word word word word word word word word word word word word word word ";

   var strr = str.split(' ')
   .reduce(function (str, part, i) {
      return str + ((i%2)===0 ? ',' : ' ') + part
   });
console.log(strr);

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!