扩展正则表达式(ERE).gitignore [英] Extended regular expressions (ERE) for .gitignore
问题描述
有没有在 .gitignore
文件中使用扩展正则表达式(ERE)的方法?例如,我想在 .gitignore
文件中使用 +
重复字符。有没有办法做到这一点?
如图所示这里,并在这个问题中详细说明, fnmatch()涉及解释glob模式,这意味着不支持正则表达式。 p>
这就是 gitignore
手册页提及:
否则,
git将模式视为(3)
与FNM_PATHNAME
标记一起使用的shell glob:模式中的通配符不会匹配/
在路径名中。
例如,Documentation / *。html
匹配文档/git.html
但不是Documentati on / ppc / ppc.html
或tools / perf / Documentation / perf.html
。
Is there a way to use extended regular expressions(ERE) in a .gitignore
file? For example I want to use the +
repetition character in a .gitignore
file. Is there a way to do that?
As illustrated here and detailed in "this question", the function fnmatch() is involved to interpret glob patterns, which means regular expressions are not supported.
This is what gitignore
man page mentions:
Otherwise,
git treats the pattern as a shell glob suitable for consumption by fnmatch(3)
with theFNM_PATHNAME
flag: wildcards in the pattern will not match a/
in the pathname.
For example, "Documentation/*.html
" matches "Documentation/git.html
" but not "Documentation/ppc/ppc.html
" or "tools/perf/Documentation/perf.html
".
You can see some correspondence between glob patterns and regular expressions in those questions.
这篇关于扩展正则表达式(ERE).gitignore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!