# Regular Expressions

**URL:** <https://www.ruby-forum.com/t/regular-expressions/146967>\
**Category:** Ruby\
**Created:** [August 27, 2008, 5:25am UTC](https://www.ruby-forum.com/t/regular-expressions/146967 "2008-08-27T05:25:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [August 27, 2008, 5:25am UTC](https://www.ruby-forum.com/t/regular-expressions/146967/1 "2008-08-27T05:25:25Z")

</div>

Pls Any one Help…  
what is the regular expressions to Extract the image url which contains  
.png .gif .jpg file extensions.

To Extract the file Name from the image url what Regular Expressions  
has to Be Used.  
Nothing Found to Be working.I m Still On the Confusion.  
Pls Help

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [August 27, 2008, 6:18am UTC](https://www.ruby-forum.com/t/regular-expressions/146967/2 "2008-08-27T06:18:15Z")

</div>

Newb N. wrote:

> Pls Any one Help…  
> what is the regular expressions to Extract the image url which contains  
> png .gif .jpg file extensions.
> 
> To Extract the file Name from the image url what Regular Expressions  
> has to Be Used.  
> Nothing Found to Be working.I m Still On the Confusion.  
> Pls Help

You have asked this question before; this might make some here concerned  
you  
won’t use the answers already provided.

Your best bet has always been Hpricot, to _find_, _store_, and  
optionally  
_erase_ the image sources. You already posted a solution with  
.search(’//img’).  
The step to _store_ the images would be something like this:

doc.search("//img").each do |img|  
puts img.attributes[‘src’]  
end

A further regexp using /.jpg$/ would match strings with .jpg on the end,  
but be  
warned there are many variations of image filenames, including, for  
example, .JPEG.

Please post back what you did with this advice (if anything!), instead  
of  
continuing to ask the same question over and over again!
