I am trying to append a parsed email to a textarea
with javascript, and this is proving to be particularly difficult because of the <
& >
in email addresses like <foo@bar.com>
Here is an example of my situation in action. https://jsfiddle.net/xxchz97L/
So I am trying to do a str.replace
on the <
& >
but nothing I do seems to work. Does anyone know how to do this?
Here is a simple excerpt of my code. I am also including jQuery.
HTML
<textarea class="form-control template_data" id="content" name="content" rows="8" cols="80"></textarea>
Javascript
var my_text = "From: Foo Bar <foo@bar.com> Date: Sat, Apr 8, 2017 at 2:29 PM";
var regEx = '/<|>/g';
my_text.replace(regEx, "*");
my_text = my_text.replace("<", "*");
my_text = my_text.replace(">", "*");
$('#content').append(my_text);
alert(my_text);
PS
I figured there would be no way to append < | >
into a textarea
as html would think I was posting HTML. If there is someone that does know how to do this please let me know.