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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -