I have a regular expression that grabs the double quotes and value for an html tag attribute:
str.match(RegEx)
str.match(RegEx)
. And then I use
str.replace(RegEx, replacementStr)
str.replace(RegEx, replacementStr)
where the
replacementStr
replacementStr
is a span tag with a class for changing the color in a
pre
pre
block.
It works like a charm when I only have 1 attribute in my html tag. But when I have 2 attributes (e.g. id and class), I get both matches in each attribute. I can't figure out why it doubling since the id and class values are different. Any insight would be great:
convertedArr.forEach(line => { // Quotes if (line.match(dblQuote)) { result = line.replace(dblQuote, `<span class="${classes[1]}">${line.match(dblQuote)}</span>`); } else { result = line; }});
convertedArr.forEach(line => { // Quotes if (line.match(dblQuote)) { result = line.replace(dblQuote, `<span class="${classes[1]}">${line.match(dblQuote)}</span>`); } else { result = line; }});