function tagWrapper(sourceText, regexPattern) {
if (!sourceText || !regexPattern) return sourceText;
let counter = 1;
const regex = new RegExp(regexPattern, 'g');
return sourceText.replace(regex, (match) => {
return `{${counter++}}`;
});
}
const sourceText = `
Attacking an aniimo depletes the yellow <style=Hint_BgL>BREAK meter</style> under its status bar. When it's <style=Hint_BgL>depleted</style>, the aniimo will enter a <style=Hint_BgL>broken state</style> and can be caught. Press <style=Hint_BgL>#kHud/Interact#z</style> to catch it.
`;
const result = tagWrapper(sourceText, '(<[^\>]+>)|(#[A-Za-z]+)|(/[A-Za-z]+)');
console.log(result);
console