Seeking help in identifying and highlighting a sentence within a paragraph (found in a textarea). The current method works fine for sentences without parentheses, but struggles with replacing strings surrounded by ""mark"" tags. Is there a way to modify the Regex pattern to successfully find and replace a string that contains parentheses? Should I first swap out all parentheses with ""/("" and ""/)"" before attempting to replace?
const text = "An economy is composed of suppliers (workers) and demanders (firms)."
const regex = new RegExp(text, "\d");
// regex returns: /The market for labor, then, is composed of suppliers (workers) and demanders (firms). /
console.log("REGEX:", regex);
let match = text.replace(regex, "<mark>$&</mark>");
console.log("MATCH:", match);