const regex = /^.*?<(\w+)\s.*?class=["']((.*?\b\s)+?[\w]+)".*/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^.*?<(\\w+)\\s.*?class=["\']((.*?\\b\\s)+?[\\w]+)".*', 'g')
const str = `<div class="flex-none pointer link-quiet flex items-center justify-center circle overflow-hidden text-white parentComplementaryColoredBackground" style="width: 28px; height: 28px;"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="icon" style="shape-rendering: geometricPrecision;"><path fill-rule="evenodd" class="" fill="currentColor" d="M9,7 L9,3.5 C9,3.224 8.776,3 8.5,3 L7.5,3 C7.224,3 7,3.224 7,3.5 L7,7 L3.5,7 C3.224,7 3,7.224 3,7.5 L3,8.5 C3,8.776 3.224,9 3.5,9 L7,9 L7,12.5 C7,12.776 7.224,13 7.5,13 L8.5,13 C8.776,13 9,12.776 9,12.5 L9,9 L12.5,9 C12.776,9 13,8.776 13,8.5 L13,7.5 C13,7.224 12.776,7 12.5,7 L9,7 Z"></path></svg></div>`;
const subst = `$1 $2`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions