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

243
Views
How to remove the last comma in javascript
let str = "Testing, how to, remove, comma"

How can I remove that last comma (,) between "remove" and "comma" using JavaScript? Preference using replace with regex

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

0

There are probably better ways than using regular expressions, but you can do this:

str.replace(/,([^,]+$)/, "$1")

const str = "Testing, how to, remove, comma"

console.log(str.replace(/,([^,]+$)/, "$1"));

The regular expression matches a comma, then in a group it matches everything that is not a comma until the end of the string. The replacement is "$1", which is the first capturing group, meaning everything after the last comma.

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!