I have written a node module with several places that use regular expressions to limit which files are manipulated as below:
if (!file.match(/\/node_modules\//) && !file.match(/\/fontawesome\//) && !file.match(/\/docs\//) && !file.match(/\/target\//) && !seenFile[file]) {
//do some processing
}
I'm trying to modify the module to accept user input as an array - i.e.:
['/node_modules/', '/fontawesome/', '/docs/', '/target/']
Is there a good way to convert the array into the regex? I know apply might work if I wasn't using file.match but I'm not sure if it will work in this instance. Thanks in advance.
RegExp(rx)must be used.