[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

regex for capturing images

Ponto André

11/28/2008 11:14:00 PM

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/figurename101...
target=_blank><img style='float:left;margin:8px' border=0
src='http://sub-domain.domain.net/path/folder/thum/figurename1010...'>...
some text</p>

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

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?
--
Posted via http://www.ruby-....

2 Answers

Constantine Karnacevych

11/29/2008 1:10:00 AM

0

> 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?

use text.scan() which matches all occurences

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

=> [["http://sub-domain.domain.net/path/folder/figurename1010...],
["http://sub-domain.domain.net/path/folder/thum/figurename1010-thumb...]]
--
Posted via http://www.ruby-....

Raveendran Jazzez

4/20/2009 9:49:00 AM

0

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/...

Install in Windows machine and enjoy with impressed images
--
Posted via http://www.ruby-....