Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
75
rated 0 times [  79] [ 4]  / answers: 1 / hits: 5983  / 10 Years ago, tue, may 13, 2014, 12:00:00

This should be easy. I have this path variable declared in a gulpfile.js:



paths = {
img: [
'src/patternlab/**/**/*.jpg',
'src/patternlab/**/**/*.png'
]
};


I'd like to use a simple OR switch for the file extension, along the lines of:



'src/patternlab/**/**/*.(jpg|png)'


But I can't find the right syntax! Have tried numerous permutations, looked through MDN etc…


More From » regex

 Answers
14

The patterns used by gulp are those promoted by npm's glob package which doesn't use a precise regex pattern matching syntax, I imagine because these things start to look horrific when matching against paths.



the documentation regarding minimatch (used by glob) cover your described case:



'/**/*.+(jpg|png|tiff)'

[#45344] Monday, May 12, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
darrell

Total Points: 109
Total Questions: 113
Total Answers: 113

Location: Zambia
Member since Sat, Oct 31, 2020
4 Years ago
;