How to remove the first occurrence of comma from a string in JavaScript

1 Answer

0 votes
let str = 'c c++, javascript, python, php';

if (str.match(/,.*,/)) { 
    str = str.replace(',', ''); 
}

console.log(str);

  
  
  
  
/*
run:
  
"c c++ javascript, python, php"
  
*/

 



answered Apr 16, 2022 by avibootz

Related questions

1 answer 240 views
1 answer 227 views
1 answer 223 views
1 answer 216 views
1 answer 212 views
...