Reputation: 10744
I want validate a url that is a image e.g.:
http://www.mydomain.com/image.jpg
http://www.mydomain.com/image.png
http://www.mydomain.com/image.jpeg
http://www.mydomain.com/image.gif
or any url or domain that end with a picture format:
I have this regex:
^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
You can see http://rubular.com/r/qGInC06jcz
But this regex don't filter extensions .jpg .jpeg .gif .png
I want only allow a url or domain that end with a picture.
Upvotes: 0
Views: 1737
Reputation: 230336
Well, you could just check the ending of the string. You don't even have to use regex here, but here we go.
\.(png|jpg|gif)$
http://rubular.com/r/5eXJWKi5xT
Upvotes: 2