Accordingly your issue the regular expression is quite simple.
/\.(jpe?g|png|gif|bmp)$/i
Do you really sure that nothing else will be used? For example, JPEG format allows both .jpg and .jpeg extensions. That’s why I put e?
pattern in the regular expression.
Example of validation could be as follows:
var filename = "/site/images/test.png";
if ( /\.(jpe?g|png|gif|bmp)$/i.test(filename) ) {
. . .
.
1
solved How to validate image file extension with regular expression using JavaScript [duplicate]