0

I have lots of markdown files with 100+ images referenced inside it.

I'm looking for a way to find & replace them.

It should remove the caption of the image & the last part of image should be appended with {width=100%}

![a caption](./img.png)

should be replaced with

![](./img.png){width=100%}

How do I do it in VSCode?

I have found the regex for image is !\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\) but don't know how to move forward?

The only thing I could figure out was appending {width=100%} in the replace input.

Currently, my find input looks like:

!\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\)

And replace input looks like:

!\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\){width=100%}

1 Answer 1

1

I found the answer while reading an answer in another tab.

find: !\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\)
replace: ![]($1){width=100%}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.