Alexey Mishustin wrote:

1/18/2011, "Grant"<emailgr...@gmail.com>  вы писали:

I came up with these but they don't seem to work reliably:

/\.google\..*\/imgres\?/
/\.google\..*\/images\?/
/\.google\..*\/products\?/

/(www.){0,1}(google\.).*\/(imgres)|(images)|(products)\?{0,1}/

That says:

(www.){0,1}

Match a four character string, beginning with 'www', zero or one time, and store the match in $1

(google\.)

Match the string 'google.' and store it in $2, Why? We know it will always be 'google.'.

.*\/

Match zero or more non-newline characters up to, and including, the last '/' character.

(imgres)

Match 'imgres' and store it in $3. Why? We know it will always be 'imgres'.

(images)

Match 'images' and store it in $4. Why? We know it will always be 'images'.

(products)

Match 'products' and store it in $5. Why? We know it will always be 'products'.

\?{0,1}

Match a '?' character zero or one times.

And finally, you use alternation which says to match either:

(www.){0,1}(google\.).*\/(imgres)

OR:

(images)

OR:

(products)\?{0,1}




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to