javascript - js replace some string with "\n" -


if have string need replace every "^^" in text break line no use <br> because using <texarea> , <textarea> display <br> text wrote code doesn't work

var text="hello ^^ world ^^ break ^^ line", txt=text.replace(/^^/g,"\n"); 

who fix this?

tnx helping

you need escape ^, correct regex /\^\^/g.

^ otherwise means "starts with" (or "exclude", if first character within square brackets).


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -