var replacements = {'<': '<', '&': '&', '>', '>'}; string.replace(/[<&>]/g, function(c) { return replacements[c]; })