I need a regular expression to validate image file extensions in javascript. Do you have one ?
I need a regular expression to validate image file extensions in javascript. Do you
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Could you explain the purpose?
Anyway here’s one assuming you support few image types.
I have put the whole regular expression within parentheses () so as to disambiguate between the slash (/) operator and RegExp object. See JSLint for more details.
Here’s the raw regex as well.
This Regex also assumes that you’re including the dot before the extension. Remove the
\.if you’re not.