How to create a Regular Expression to Validate a HTTP Image URL
by
Doug
Updated July 15, 2010
Here's an example of a regular expression for validating an image url that ends with .gif, .jpg, .jpeg, .bmp or .png.
Here's the image url regex:
http://([\w-]+\.)+[\w-]+(/[\w- ./]*)+\.(?:gif|jpg|jpeg|png|bmp|GIF|JPEG|JPG|PNG|BMP|Gif|Jpg|Jpeg|Png|Bmp)$
It will validate an image url such as:
http://ec1.images-amazon.com/images/P/B000H407JS.01-A13VEIVXU1FLP2._SCLZZZZZZZ_V43320573_AA267_.jpg
Note: The regex example was tested using ASP.NET with C#.