How to use basic regular expressions within gulp.src?

时间秒杀一切 提交于 2019-12-22 07:11:11

问题


I'm trying to select two files with gulp.src: highcharts.js and highcharts.src.js.

Of course I know I could add explicitly these two with an array expression, but for learning purposes I'm trying to write a single expression for them.

I've read that one can use simple regular expression syntax but it's not clear how.

I tried

gulp.src("highcharts(\.src)?\.js")

but it didn't match any files.


回答1:


Gulp uses glob which doesn't support the regular expressions you're normally used to. It uses special globbing patterns that are optimized to matching files.

Your example could be written as:

gulp.src('highcharts?(.src).js')

Check out the glob primer for more examples of what's possible with glob.



来源:https://stackoverflow.com/questions/36305156/how-to-use-basic-regular-expressions-within-gulp-src

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