javascript - Remove first occurrence of comma in a string -


i looking way remove first occurrence of comma in string, example

"some text1, tex2, text3" 

should return instead:

"some text1 text2, tex3" 

so, function should if there's more 1 comma, , if there is, should remove first occurrence. solved regex don't know how write it, ideas ?

this it:

if (str.match(/,.*,/)) { // check if there 2 commas     str = str.replace(',', ''); // remove first 1 } 

when use replace method string rather re, replaces first match.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -