[英]How can I exclude a string if it ends in “.d.ts”?
I am using regex type glob to include files in gulp. 我正在使用正则表达式类型glob在gulp中包含文件。 How can I use a regex to ignore strings that end with a ".d.ts" but include all others?
如何使用正则表达式忽略以“ .d.ts”结尾但包含所有其他字符串?
Already I have this: 我已经有这个了:
"app/*.*"
but it's including filenames with any ending. 但其中包括任何结尾的文件名。
Is there a way I can limit it to just those not ending in .d.ts? 有没有办法可以将它限制在那些不以.d.ts结尾的那些? So for example these would be okay:
所以例如这些都可以:
app/abc.html
app/abc.js
app/abc.ts
But this would not 但这不会
app/abc.d.ts
In your src
definition, you can use bang ( !
) to exclude paths, like: 在
src
定义中,可以使用bang( !
)排除路径,例如:
gulp.src(['path/to/src/**/*.*', '!path/to/src/**/*.d.ts'])
The minimatch documentation discusses the bang syntax. minimatch文档讨论了bang语法。
Just noticed this related question has additional details. 刚刚注意到这个相关问题有其他细节。
.*(?<!\.d\.ts)$
(assuming lookbehind assertions are supported by your regex flavor. I dont know "gulp") (假设您的正则表达式支持lookbehind断言。我不知道“gulp”)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.