Home > Software engineering >  replace markdown images without alt with filename using regex using find & replace in vscode?
replace markdown images without alt with filename using regex using find & replace in vscode?

Time:11-11

i have multiple markdown files that contain images without alt that look like:

# my file

![](./filename-1.png)

# this is an example image

![](./this-is-a-an-example-image.png)

i want to replace them with alt from the filename but without the .png extension & without ./ & replacing hyphens (- ) with empty spaces.

so the above markdown would look like:

# my file

![filename 1](./filename-1.png)

# this is an example image

![this is an example image](./this-is-an-example-image.png)

i can't do this manually as i have 100 images so would love to automate this with a regex using vscode's find & replace.

i had add markdown image alt text

  • Related