-1

I need a regex for valid url image, example: http://domain.something.jpg

protocol: http,https,ftp estension: jpg,png,gif,bmp

Can you help me please?

paganotti
  • 5,451
  • 7
  • 34
  • 47
  • What about `http://foo.com/dynamic`? Do you consider this as *valid image* assuming that this server side script sets the `Content-Type: 'image/jpg'` and writes a valid image into the response? – Darin Dimitrov Jan 21 '12 at 09:38
  • possible duplicate of [Regex to check if valid URL that ends in .jpg, .png, or .gif](http://stackoverflow.com/questions/169625/regex-to-check-if-valid-url-that-ends-in-jpg-png-or-gif) – Mat Jan 21 '12 at 09:38
  • what did you try? what's the difficulty? – Marcelo Diniz Jan 21 '12 at 09:39

2 Answers2

3

Maybe something like that:

"^(https?|ftp)://.*(jpeg|png|gif|bmp)"
Ortwin Angermeier
  • 5,755
  • 1
  • 32
  • 34
1

Try this,

/^((https?|ftp):)?\/\/.*(jpeg|jpg|png|gif|bmp)$/
Rahul
  • 1,838
  • 16
  • 32