Search code examples
javascriptregexgulpfilenamesprefix

JavaScript match files that contains certain prefix


I have a gulp.src on a task but I want to match all the files that contain a certain word as a prefix e.g.:

gulp.src('./mydir/project.build-blessed1.css')

But there can be N files with different numbers, blessed1, blessed2, blessed3

How can I make it match any file that starts with that and has the .css extension on the same line, without using a function?


Solution

  • if you're not using an old implemetation of gulp you can use '*' as wild card even in the middle of a path so something like:

    gulp.src('./mydir/project.build-blessed*.css')
    

    should work

    You can see the doc here https://github.com/gulpjs/gulp/blob/master/docs/API.md