2021-08-24
VSCode oembed link update with RegEx
vscode, oembed, regex, gist
vscode, oembed, regex, gist
Image by Jarkko Mänty from Pixabay
My previous Gatsby blog required gist:dance2die/{gistID} format to process GitHub gists.
To take advantage of oEmbed links, I decided to use a full URL.
There were over 300+ gists to process and manual replace seemed ridiculous.
Found this article, VS Code: Search-and-Replace Regex, which explained how to replace regex expressions to replace.
When I matched gist:(.*?) I saw 328 matches. I can refer to the matched group (.*?), which contains dance2die/{gistID} using $1 (first match). I can now append the gist link to the match with https://gist.github.com/$1.
VSCode shows the replacement string inline, and confirmed they work before replacing.