Thanks for taking time for Reply.
My Problem Has not Sorted Out.Actually i m Extracting These images
from other Webpages.
Using Hpricot i Got all the Image urls.I did code like below
It has given all the image url.But for example i have image urls even
like below
In this case the first one is valid image url because it has jpg file
extensions.so i need to display the image urls which has the
.jpg,.png,gif extensions only…
Is this possible using Regular Expressions?
Pls Help me out To Understand
In this case the first one is valid image url because it has jpg
file
extensions.so i need to display the image urls which has the
.jpg,.png,gif extensions only…
If you want to understand more then you should read more
documentation and
wikipedia on your topic. Also test carefully your expressions by an irb
session. Often it helps if you write a simple test to understand your
problem.
In my opinion a great ressource for regular expressions is
Again I have to start from the scratch…From The beginning itself i got
into problem.Actually my problem is I want to extract the image tag
which contains image file extensions like .jpg .png.But currently i m
using this RegEx (/<img.*?>/).But it gives me img tags without .jpg or
.png file extensions.
So pls Kindly Help Me All…I m really struggling.
You People Favour me and thanks much.
Again I have to start from the scratch…From The beginning itself i
got
into problem.Actually my problem is I want to extract the image tag
which contains image file extensions like .jpg .png.
You define the last part of your target: ends with .jpg or .png
But currently i m
using this RegEx (/<img.*?>/).But it gives me img tags without .jpg or
.png file extensions.
That regular expression doesn’t match the end: .jpg or .png
Think about what your regex will match. Try it yourself with irb.
You want to match an url string with a specific ending.
Try to match the start, the end and all characters between, without
matching
characters pre and post of your target.
What characters are allowed in your target?
What substrings should be a part of the string you want to match?
What characters are the bounces that you don’t want to match?
Please try to solve the problem yourself. You should learn to think
about the
problem you want to solve, but I have included one solution.
Don’t just copy 'n paste a solution.
regards, Sandor
Szücs–
P.S.
What characters are allowed in your target?
a-zA-Z0-9:_%-./
What substrings should be a part of the string you want to match?
the last part have to be: .png or .jpg or .gif
What characters are the bounces that you don’t want to match?
In my example above it is ’ . Is this character a part of our target?
no!