Regex for capturing images


#1

ok, i’ve written this regex:
/(https?:(?:confused:\w.-)*(?:.gif|.jpg|.bmp|.png|.jpeg))/i

i’ve tested it on rubular.

and for this example text:

some text

rubular outputs me this:
Match captures:
Result 1

  1. http://sub-domain.domain.net/path/folder/figurename1010.jpg
    Result 2

http://sub-domain.domain.net/path/folder/thum/figurename1010-thumb.jpg

but in my code:
matchdata =
text.match(/(https?:(?:confused:[a-zA-Z].-\d*)*(?:.gif|.jpg|.bmp|.png|.jpeg))/i).captures
puts matchdata.size

size prints me “1”.

am i capturing wrong?


#2

but in my code:
matchdata =
text.match(/(https?:(?:confused:[a-zA-Z].-\d*)*(?:.gif|.jpg|.bmp|.png|.jpeg))/i).captures
puts matchdata.size

size prints me “1”.

am i capturing wrong?

use text.scan() which matches all occurences

p
text.scan(/(https?:(?:confused:\w.-)*(?:.gif|.jpg|.bmp|.png|.jpeg))/im)

=> [[“http://sub-domain.domain.net/path/folder/figurename1010.jpg”],
[“http://sub-domain.domain.net/path/folder/thum/figurename1010-thumb.jpg”]]


#3

Hi All,

Get all images from given URL

Desktop Application from jazzez

Kindly go through below link and download the EXE file.

http://www.box.net/shared/m5vxqpr3r1

Install in Windows machine and enjoy with impressed images