Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SebbeJohansson/3444408646d95383b75434c61c46933c to your computer and use it in GitHub Desktop.
Save SebbeJohansson/3444408646d95383b75434c61c46933c to your computer and use it in GitHub Desktop.
const regex = /(?<start><img)(?<middle>.*?)(?<end>\/>)/ig;
const newText = col.RichText.replaceAll(regex, (match, p1, p2, p3, offset, string, namedGroups) => {
return `${namedGroups.start} loading="lazy" ${namedGroups.middle} ${namedGroups.end}`;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment