Skip to content

Instantly share code, notes, and snippets.

@lyuehh
Created March 28, 2013 03:15
Show Gist options
  • Save lyuehh/5260274 to your computer and use it in GitHub Desktop.
Save lyuehh/5260274 to your computer and use it in GitHub Desktop.
function parseHTMLToText(html) {
if( html ){
html = html.replace(/\n/g,"");
html = html.replace(/<br \/>|<br>|<\/p>|<\/P>|<\/li>|<\/LI>/g,"\n"); //li special
html = html.replace(/<[^>]+>/g,"");
html = html.replace(/\t+/g, "");
html = html.replace(/&nbsp;/g,"");
}else{
html = "";
}
return html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment