简体   繁体   中英

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.

After refining, this could be it:

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

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

(removed the capture Groups again)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM