Please consider the following HTML
element: This is some example code which contains tabs
This is some example code which contains tabs
Try this:
var tab = RegExp("\\t", "g"); document.getElementById("text").value = document.getElementById("text").value.replace(tab,' ');