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
Post a Comment