本文介绍了仅与内部Markdown链接匹配但不带.md扩展名的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含大量Markdown文件的项目,这些文件包含内部和外部(以http
开头)链接.其中一些内部链接没有.md文件扩展名,因此在Jekyll外部渲染时不起作用.
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.
示例:
[link text 1](internal-link)
[link text 2](internal-link-2.md)
[link text 3](http://external-link...)
我正在寻找一个仅与这三种情况中的第一种匹配的正则表达式-不带.md
文件扩展名的内部链接.
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
(再次删除了捕获组)
这篇关于仅与内部Markdown链接匹配但不带.md扩展名的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!