String.htmlEdit
The Javascript function htmlEdit removes HTML entities
from a string and replaces them with literal characters,
suitable for editing in an input. The characters replaced
are ampersand '&', less-than '<', greater-than '>'
and non-breaking space ' '.
String.prototype.htmlEdit = function() {
return this.replace(/&/g,'&')
.replace(/</g,'<')
.replace(/>/g,'>')
.replace(/ /g,' ');
}