<script language="javascript" type="text/javascript">
function textremv() {
var output = document.getElementById("content").value;
output = output.replace(/\s/g, "")
output = output.replace(/-/g, "")
output = output.replace(/,/g, ", ")
output = output2
output2 = Array.from(new Set(output2.split(','))).toString();
document.getElementById("output").innerHTML = output;
}
</script>
<textarea rows='5' cols='50' id='content'></textarea>
<input type='button' value='Extract Text' onclick='textremv()'/>
<div id="output"></div>
Purpose: Aiming to break down phone numbers to 10 characters by first removing extra spaces, removing dashes, and then adding a space after the comma.
Ex: 555- 555-5555, 555-5555555, 555555-5555 in a textarea would return 5555555555, 5555555555, 5555555555
GOAL: The code above works kind of if I remove "output = output2." I was trying to save the "fixes" into a new var. What I want to do is remove duplicates from the output which the code above is removing duplicates prior to the format. So the only return I would get would just be 5555555555 since there are duplicates in that example.
I'm not married to the above code if there's another way in javascript. I did research other questions on here but what I'm finding is they don't really mesh up with the output that I'm using.
EDIT: T.J's answer worked for me. I also made another textarea and added this
document.getElementById("content2").innerHTML = output;
where content2 is the name of another text area incase anyone else finds this and wants to have an easy copy/paste option.