jellis
jellis

Reputation: 160

Matching file extensions - regex nodejs

I'm currently running a regular expression in a node file that's designed to copy my custom fontello icon font files across to the public directory. To ensure I'm not copying irrelevant files I'm using the following:

var match = new RegExp(/\.(woff|svg|ttf|eot)/g);
if (match.test(fileName)) {
    // Do something
}

As I cycle through the fonts available, the only two that are being matched are

app.svg
app.eot

The app.ttf and app.woff files are not matching the expression.

I have tried out the expression over at http://www.regexr.com/ and it appears to work for my purposes. Keep in mind that I don't require much more stringent testing than this as there is only a handful of files in that directory.

If anybody can give me some guidance I would be most appreciative.

Upvotes: 1

Views: 4478

Answers (1)

vks
vks

Reputation: 67968

Your regex is correct.Tried it.

See

Upvotes: 1

Related Questions