regex for capturing images

P

Ponto André

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

i've tested it on rubular.

and for this example text:
<p><a href='http://sub-domain.domain.net/path/folder/figurename1010.jpg'
target=_blank><img style='float:left;margin:8px' border=0
src='http://sub-domain.domain.net/path/folder/thum/figurename1010-thumb.jpg'></a>
some text</p>

rubular outputs me this:
Match captures:
Result 1
1. http://sub-domain.domain.net/path/folder/figurename1010.jpg
Result 2
1.
http://sub-domain.domain.net/path/folder/thum/figurename1010-thumb.jpg

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

size prints me "1".

am i capturing wrong?
 
C

Constantine Karnacevych

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top