Shellait,
<script>
var jsScript = 'var text = "hello world"; alert(text);';
function fn(str, num) {
var reg = /\w+|".*?"|'.*?'/g,
arr = str.match(reg);
if (arr) {
arr = arr.reduce(function(a, b, i) {
if (!/"/.test(b)) a.push(i);
return a
}, []);
for (; arr.length > num;) arr.splice(Math.random() * arr.length | 0, 1);
num = 0;
str = str.replace(reg, function(a) {
return arr.indexOf(num++) > -1 ? "" : a
})
}
return str
};
for (var i=0; i<5; i++) {document.write(fn(jsScript, 2)+"<br>")}
</script>