Skip to content

Instantly share code, notes, and snippets.

@FranciscoMoretti
Last active October 23, 2021 23:55
Show Gist options
  • Save FranciscoMoretti/3977b1c8c393e606579b9349086c1715 to your computer and use it in GitHub Desktop.
Save FranciscoMoretti/3977b1c8c393e606579b9349086c1715 to your computer and use it in GitHub Desktop.
Search and replace with regex groups in VS Code - MD image to Next JS Image

This example converts a MD image to a Next JS Image. HEIGHT and WIDTH need to be replaced manually.

Text to replace

![Numeric Algorithms](/public/static/images/talk/bFSnXNIsK4A/numeric_algorithms.png)

Regex to use in the Search field. Group 1 is the title, and group 2 is the src.

!\[(.*)\]\(/public(.*)\)

Regex to use in the replace field

<Image
  alt={`$1`}
  src={`$2`}
  width={WIDTH}
  height={HEIGHT}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment