I want to use regex to allow/reject files during fileupload with a specific file type.
This is the working regex /(\.|\/)(xlsx)$/i
expected output that I want to achieve.
What I'm trying is instead of hardcode the filetype, I want to pass a variable that holds filetype into the regex.
var fileType = 'xlsx';
var regexText = new RegExp("/(\.|\/)(" + fileType + ")$/i");
but the current output of regexText is /\/(.|\/)(xlsx)$\/i/
this is not same as expected output. How do I can get same output as mentioned above by using a variable without hardcode? Is there solution without using the RegExp that can give the same expected output?