Intermediate Algorithm Scripting - Convert HTML Entities

What are the inside parenthesis for in this case? .replace(/([&<>"'])/g //// i understand the reason for all the other symbols just not the parenthesis right before and after the square brackets

Your code so far

function convertHTML(str) {

convertHTML("Dolce & Gabbana");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 Edg/107.0.1418.56

Challenge: Intermediate Algorithm Scripting - Convert HTML Entities

Link to the challenge:

The parens create a capture group, which allows you to refer to the value captured inside the parens in other places, such as when you want to replace them with something else using the replace method.

1 Like

isnt that what the do as well though? capture a class/ group? oops that supposed to be just the opening and closing square brackets but makes a box

The square brackets allow you to search on a range of characters but they don’t allow you to reference the character they find anywhere else. So the brackets aren’t technically “capturing” anything, they are just finding/matching something.

1 Like

Oh ok, yeah i understand the difference now, thank you bbsmooth :grinning:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.