[英]Why doesn't '*' work as a perl regexp in my .Rbuildignore file?
When I try to build a package with the following in my .Rbuildignore file, 当我尝试在我的.Rbuildignore文件中构建包含以下内容的包时,
*pdf
*Rdata
I get the errors: 我得到错误:
Warning in readLines(ignore_file) : incomplete final line found on '/home/user/project/.Rbuildignore'
readLines(ignore_file)中的警告:在'/home/user/project/.Rbuildignore'上找到不完整的最后一行
and 和
invalid regular expression '*pdf'
无效的正则表达式'* pdf'
I thought '*' was a wildcard for one or more characters? 我以为'*'是一个或多个角色的通配符?
See help(regex)
for help on regular expression, esp. 有关
help(regex)
的帮助,请参阅help(regex)
,尤其是 the Perl variant, and try Perl变种,并尝试
.*pdf
.*Rdata
instead. 代替。 The 'dot' matches any chartacter, and the 'star' says that it can repeat zero or more times.
'dot'匹配任何图表,'star'表示它可以重复零次或多次。 I just tried it on a package of mine and this did successfully ignore a pdf vignette as we asked it to.
我只是尝试了我的一个包,这确实忽略了我们要求的pdf插图。
There are two styles of pattern matching for files: 文件的模式匹配有两种样式:
You seem to be thinking in terms of globs but .Rbuildignore uses regular expressions. 你似乎在考虑使用globs,但是.Rbuildignore使用正则表达式。 To convert a glob to a regular expression try
要将glob转换为正则表达式,请尝试
> glob2rx("*pdf")
[1] "^.*pdf$"
In a perl regexp, use .*?
在perl regexp中,使用
.*?
as a wildcard. 作为通配符。
But I think that what you actually want is pdf$
and Rdata$
as entries in .Rbuildignore seem to affect files whose paths they match only partially, too. 但我认为你真正想要的是
pdf$
和Rdata$
因为Rdata$
中的条目似乎也影响了它们只匹配部分路径的文件。 $
means "end of the path". $
表示“路径的终点”。
*
is a quantifier that attaches to a previous expression to allow between 0 and infinite repetitions of it. *
是一个量化器,它附加到前一个表达式,允许在0和无限重复之间。 Since you have not preceded the quantifier with an expression, this is an error. 由于您没有在量词之前加上表达式,因此这是一个错误。
.
is an expression that matches any character. 是一个匹配任何字符的表达式。 So I suspect that you want
.*pdf
, .*Rdata
, etc. 所以我怀疑你想要
.*pdf
, .*Rdata
等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.