Convert HTML Character Entities back to regular text using javascript -


the questions says :)

eg. have >, need > using javascript

update: seems jquery easy way out. but, nice have lightweight solution. more function capable itself.

you this:

string.prototype.decodehtml = function() {     var map = {"gt":">" /* , … */};     return this.replace(/&(#(?:x[0-9a-f]+|\d+)|[a-z]+);?/gi, function($0, $1) {         if ($1[0] === "#") {             return string.fromcharcode($1[1].tolowercase() === "x" ? parseint($1.substr(2), 16)  : parseint($1.substr(1), 10));         } else {             return map.hasownproperty($1) ? map[$1] : $0;         }     }); }; 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -