How to remove the first occurrence of comma from a string in Node.js

1 Answer

0 votes
let str = 'c c++, nodejs, python, php';
 
if (str.match(/,.*,/)) { 
    str = str.replace(',', ''); 
}
 
console.log(str);
 
   
   
   
   
/*
run:
   
c c++ nodejs, python, php
   
*/

 



answered Apr 16, 2022 by avibootz
...