Regex Help to find specific links

Discussion in 'PHP' started by Softbrix, Jan 31, 2007.

  1. #1
    I'm trying to write a php script which will phrase out valid links from a file. all the links have jl.cgi/xxx where xxx is numbers. I use the following regex below which works but it also give me a bunch of links that don't match the criteia.

    preg_match_all("/http:\/\/(.+?)\/jl.cgi\/\d+/im", $data, $scraped);

    so I want to scrape http://www.xxx.com/jl.cgi/123
     
    Softbrix, Jan 31, 2007 IP
  2. picouli

    picouli Peon

    Messages:
    760
    Likes Received:
    89
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Seems fine to me, the only thing I'd change is:

    preg_match_all("/http:\/\/(.+?)\/jl\.cgi\/\d+/im", $data, $scraped);

    Notice the '\' in from the dot in '.cgi' - other than that I can't see anything wrong... What unwanted results are you getting? I mean, how are those links?
     
    picouli, Feb 1, 2007 IP