Skip to content

Instantly share code, notes, and snippets.

@mintyPT
Last active February 19, 2016 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mintyPT/99172ee907e7e93421b7 to your computer and use it in GitHub Desktop.
Save mintyPT/99172ee907e7e93421b7 to your computer and use it in GitHub Desktop.
Some kind of cleaning function, no ideia why I made this though
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
#input, #output {
width: 500px;
border: 1px solid #ccc;
}
#input {
height: 300px;
}
#output {
min-height: 300px;
}
</style>
</head>
<body>
<!-- -->
<!-- nostrud exercitation <span clas="23ewcs23 12312e 123fcs xz">santos</span> dolore lablaborum. -->
<textarea id="input"></textarea>
<br>
<button id="limpar">limpar</button>
<br>
<br>
<hr>
<div id="output"></div>
<script>
function reEscape(s) {
return s.replace(/<span[\s\w="]*>(.*)<\/span>/mg, "$1");
}
function strip(html)
{
var tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText || "";
}
document.getElementById('limpar').addEventListener("click", function(){
console.log('run');
var text = document.getElementById('input').value;
//text.replace(/<(?:.|\n)*?>/gm, '');
document.getElementById('output').innerText = strip(text);
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment