I have the following string
with various HTML
tags inside:
let str = "3 HTML tags are: <html>, <a href src='www.google.com'>, and <body>.";
I want to replace each HTML
tag with an arbitrary value outline within a map
:
let map = {
"<html>":"<HTML>",
"<a*>":"<A HREF SRC='..'",
"<body>":"<BODY>"
};
However, for certain tags like <a href="..."
, I want to simply leave the href
value intact and simply replace the <a href="www.google.com">
with <A HREF="www.google.com">
I've tried to add wildcard characters inside the value for the respective key but it's just being hardcoded as an asterisk (*
).
Is there a way to accomplish this? Any and all documentation is welcome!
My JSFiddle can be found here