Skip to content

Instantly share code, notes, and snippets.

@sudowork
Created January 29, 2013 21:32
Show Gist options
  • Save sudowork/4668091 to your computer and use it in GitHub Desktop.
Save sudowork/4668091 to your computer and use it in GitHub Desktop.
// From JavaScript The Good Parts
String.prototype.deentityify = (function () {
var entity = {
quot: '"',
lt: '<',
gt: '>'
};
return function ( ) {
return this.replace(/&([^&;]+);/g, function (a, b) {
var r = entity[b];
return typeof r === 'string' ? r : a;
});
};
}());
document.writeln('&lt;&quot;&gt;'.deentityify()); // <">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment