问题
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