I've a bunch of Markdown links with whitespace, and I need to replace the whitespace with %20
. So far I've hacked a few solutions, but none that work in VSCode, or do exactly what I'm looking for.
This is the URL format conversion I need:
[My link](../../_resources/my resource.jpg)
[My link](../../_resources/my%20resource.jpg)
\s+(?=[^(\)]*\))
will work on any whitespace inside brackets - but gives false positives as it works on anything with brackets.
(?:\]\(|(?!^)\G)[^]\s]*\K\h+
does the job, but I'm getting some "Invalid Escape Character" messages in VSCode, so I assume the language isn't compatible.
I've been trying to identify the link on the characters ](
but as I'm relatively new to regex, struggling a bit.
I tried with this regex: (?<=\]\()s\+
as this (?<=\]\().+
correctly identifies the url, but it doesn't work.
Where am I going wrong here? Thanks in advance!
EDIT: VSCode find in files doesn't support variable length lookbehind, even though find/replace in the open file does support this. Open to any other solutions before I dive into writing a script!