1/18/2011, "John W. Krahn" <jwkr...@shaw.ca> вы писали:

>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

The point should be escaped as I wrote already. So, match the string
'www.', zero or one time.

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

I used brackets not for storing but for combining in order to use the
combined patterns in alternation.

>And finally, you use alternation which says to match either:
>
>(www.){0,1}(google\.).*\/(imgres)
>
>OR:
>
>(images)
>
>OR:
>
>(products)\?{0,1}

Oops. Evidently, I was wrong in this combining... I meant

(imgres)

OR

(images)

OR

(products)

--

Regards,
Alex

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