Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use basic regular expressions within gulp.src?

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.

like image 463
Zoltán Tamási Avatar asked Mar 30 '16 09:03

Zoltán Tamási


1 Answers

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.

like image 123
Sven Schoenung Avatar answered Oct 20 '22 14:10

Sven Schoenung