L
lkrubner
PHP has a function called nl2br() which takes all the newlines in a
string and turns them into break tags <br>. I need to do the same in
javascript. Is this about right? I'm not sure how one is supposed to
reference invisible characters in Javascript strings. I took an example
on the web and tried to modify it to my uses.
function nl2br_js(myString) {
var regX = /\n/gi ;
s = new String(myString);
s = s.replace(regX, "<br /> \n");
return s;
}
After looking around quite a bit using Google, I still couldn't find
out what the gi in the above example is for. What is it?
string and turns them into break tags <br>. I need to do the same in
javascript. Is this about right? I'm not sure how one is supposed to
reference invisible characters in Javascript strings. I took an example
on the web and tried to modify it to my uses.
function nl2br_js(myString) {
var regX = /\n/gi ;
s = new String(myString);
s = s.replace(regX, "<br /> \n");
return s;
}
After looking around quite a bit using Google, I still couldn't find
out what the gi in the above example is for. What is it?