Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: very quick link regex

by Anonymous Monk
on Aug 03, 2007 at 04:31 UTC ( [id://630444]=note: print w/replies, xml ) Need Help??


in reply to very quick link regex

actually after doing a little more research I found that the link is MORE dynamic than I thought. I need to match anything after page.com/files\d+... until after the .jpg . No other part of the page has /files\d+ so if it finds a match, it'll always be the right one. Can someone help with this?

Replies are listed 'Best First'.
Re^2: very quick link regex
by varian (Chaplain) on Aug 03, 2007 at 07:40 UTC
    You were very close to result already.
    /(.+)+\.jpg
    In this last part of your regexp the dot-plus will match all up to the end of line. The remaining '.jpg' part will not be found and therefore the regexp never matches.

    The solution is to make the dot-plus part of the regexp less greedy, change the part above to:

    /(.+?)\.jpg
Re^2: very quick link regex
by atemon (Chaplain) on Aug 03, 2007 at 05:16 UTC

    try

    my $content2 =~ m#(www\.page\.com/files\d+/.+\.jpg)#i;
    Note: the code is NOT tested.

    Cheers !

    --VC



    There are three sides to any argument.....
    your side, my side and the right side.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://630444]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2025-11-17 03:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (72 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.