Tiny bit of preg match doing my nut in

Discussion in 'PHP' started by cornetofreak, Jun 2, 2008.

  1. #1
    I must be bline here im using preg n match to strip html content using curl...

    BUT i am havin mad trouble over tiny code it was working befor but when i tried to fine tune it it went poof!! and stoped working

    <div id='news-id-3526'>
    DATA I WANT TO COLLECT AND THE ID NUMBERS MUST BE VARIABLE

    and i want to end it at the lst div found...

    <DIV> all case insencative

    heres what i got

    preg_match_all("/\<div id='news-id-(.*)'\>\<\/div\>/",$buffer, $download);

    the buffer is curl and the download is out put PLEASE HELP tanks
     
    cornetofreak, Jun 2, 2008 IP
  2. Aequitas

    Aequitas Guest

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your Regex expression is all wrong try this.

    
    preg_match_all('/<div\sid=\'news\-id\-3526\'>(.*?)<\/div>/",$buffer, $download);
    
    PHP:
    Also if your div content is on more then 1 line you may have to do the following to your content before doing your preg match.

    $content = str_replace("\r", "", $content); // Strip Returns
        $content = str_replace("\n", "", $content); // Strip New Lines
    PHP:
     
    Aequitas, Jun 2, 2008 IP