Learn How to Do-It-Yourself!

How to create a Regular Expression to Validate a HTTP Image URL


Here's an example of a regular expression for validating a 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 a 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#.


_______________________________________
Save this  Email this  |  Digg this!  |  del.icio.us  |  RSS 

Add your comment

by Anonymous - Already have an account? Login now!
Your Name:  

Title:  

Comment:  
Join now for free to keep track of all your comments and have them appear instantly.

Sponsored Links

Search for keywords: