Hay guys, i need help with a REGEX.
I have the got the value of an input box with this.
fileext = filename.split(".").reverse()[0];
I need to make sure this is a jpg, gif or png. Else throw an error.
Thanks
Hay guys, i need help with a REGEX.
I have the got the value of an input box with this.
fileext = filename.split(".").reverse()[0];
I need to make sure this is a jpg, gif or png. Else throw an error.
Thanks
Try using only regular expressions:
/\.(jpe?g|png|gif)$/i.test(filename);
This will check that the string ends with the correct extension.