Regex replace linebreak and comma

i’ve a question about regex, i’ve a text and it looks like below :

car,model,serie
,Mercedes,324,1,
,BMW,23423,1,
,OPEL,54322,1,

it should look like:

car,model,serie
Mercedes,324,1,
BMW,23423,1,
OPEL,54322,1,

so without commas at the beginning of the text.

What i tried :

var str2 = str.replace(/n|r/g, ""); 

but somehow, i couldn’t add comma in regex.

can anyone help me?
Thanks in advance.


Source: regex

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.