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 147 views
1 answer 143 views
1 answer 133 views
1 answer 132 views
1 answer 135 views
...