Regular Expression Question

Discussion in 'PHP' started by Darkhodge, Feb 14, 2007.

  1. #1
    Heya,


    I want to use preg_match to find the number of listings on DMOZ. I have a variable, $v, which contains all the source code of a page. How do I write the regex to find "15" (the second one) in the following code?


    Thanks,

    Hodge :)
     
    Darkhodge, Feb 14, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    preg_match('/Open Directory Sites<\/b><\/font>\s+?\(\d+-\d+ of (\d+)\)/', $v, $match);
    
    echo $match[1];
    
    
    PHP:
     
    nico_swd, Feb 14, 2007 IP