regex - Javascript regexp replace newline -
i had
return value.replace("\n","<br>") .replace("\r","<br>") .replace("<br><br>","<br>");
which replaced first occurence of \n
i found that, replace occurences, should replace string
/string/g
so did:
return value.replace("/\n/g","<br>") .replace("/\r/g","<br>") .replace("/<br><br>/g","<br>");
but seems if missing something, since nothing replaced.
remove double quotes around regex:
return value.replace(/\n/g,"<br>") .replace(/\r/g,"<br>") .replace(/<br><br>/g,"<br>");
Comments
Post a Comment