janpio
janpio

Reputation: 10922

Regular expression that only matches internal Markdown links without .md extension

I have a project with lots of Markdown files that include internal and external (start with http) links. Some of these internal links don't have a .md file extension and so don't work when rendered outside of Jekyll.

Examples:

[link text 1](internal-link)
[link text 2](internal-link-2.md)
[link text 3](http://external-link...)

I am looking for a regular expression that only matches the first of these three cases - internal link without .md file extension.

Upvotes: 0

Views: 812

Answers (1)

Patrick Artner
Patrick Artner

Reputation: 51683

After refining, this could be it:

\[[^]]+\]\((?!http:)(?!.+\.md).+\)

https://regex101.com/r/0uW1cl/5

(removed the capture Groups again)

Upvotes: 1

Related Questions