I'm trying to replace something multi line in Javascript, IE is giving me trouble.
pastebin here:http://jsbin.com/olahi/edit
Explanation of what I'm trying to do: Here's my HTML:
<textarea id="editthis">
Hello from JS Bin
Whats up from JS Bin
Whats
up from JS Bin
</textarea >
And my JS:
jQuery.fn.runReplacement= function(expr) {
return this.each(function() {
this.innerHTML = this.innerHTML
.replace(/Hello/ig, "Hey")
.replace(/Whats ?\n? ?up/ig, "Hey")
;
});
};
$(function() {
$("textarea").runReplacement();
});
In my JS(jQuery) example, I'm just trying to replace Hello and 'Whats up' with 'Hey'.
In IE the first two lines work, but not the third(and fourth). In Chrome and FF all 4 lines work.
I don't see any reason why IE should not support \n. Did I do something wrong?
Thanks in advance.
Thanks everyone, it's good to learn that IE needs /r/n rather than just /n.
Any suggestions for making my code cross-browser, rather than just IE or everything else.
Thanks!