You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
508 B
JavaScript
17 lines
508 B
JavaScript
function escape_HTML(html_str) {
|
|
'use strict';
|
|
|
|
return html_str.replace(/[&<>"]/g, function (tag) {
|
|
var chars_to_replace = {
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
'"': '"'
|
|
};
|
|
|
|
return chars_to_replace[tag] || tag;
|
|
});
|
|
}
|
|
|
|
console.log(escape_HTML('<a href="javascript-string-exercise-17.php" target="_blank">'));
|
|
</a> |