I am looking for a way to remove the first occurrence of a comma in a string, for example
\"some text1, some tex2, some text3\"
should retu
String.prototype.replace replaces only the first occurence of the match:
"some text1, some tex2, some text3".replace(',', '')
// => "some text1 some tex2, some text3"
Global replacement occurs only when you specify the regular expression with g flag.
var str = ",.,.";
if (str.match(/,/g).length > 1) // if there's more than one comma
str = str.replace(',', '');