Find and replace special symbols but save the value between them

PHOTO EMBED

Tue Mar 14 2023 16:48:47 GMT+0000 (Coordinated Universal Time)

Saved by @viktor_atanasov

export const findAndReplaceSpecialSymbols = (text?: string) => {
  if (!text) return "";
  const textToReplace = _isArray(text) ? text[0] : text;

  const pattern = /{{(.*?)}}/g;
  return textToReplace.replace(
    pattern,
    '<span>$1</span>'
  );
};
content_copyCOPY