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

杀马特。学长 韩版系。学妹 提交于 2019-12-24 18:13:28

问题


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.


回答1:


After refining, this could be it:

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

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

(removed the capture Groups again)



来源:https://stackoverflow.com/questions/46850046/regular-expression-that-only-matches-internal-markdown-links-without-md-extensi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!