Preg Match Regex - Should work but it doesn't

Discussion in 'PHP' started by eiso, Aug 2, 2007.

  1. #1
    Dear DP Members,

    My source ($text_raw) is as the following:

    <td valign=top>
    
    blablablabla</br>blablablanla
    
    </td>
    Code (markup):
    And I want to extract the text between <td valign=top> and </td> having worked with regex's before I thought the following would work:

    $pattern = '#<td valign=top>(.*?)</td>#';
    	
    preg_match($pattern, $text_raw, $text_r2);
    Code (markup):
    Why when I print_r the array I see an empty array, I know the mistake lies in my regex but I don't see where I went wrong.

    Thank you,

    Eiso
     
    eiso, Aug 2, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Add the s modifier to the pattern.
     
    nico_swd, Aug 2, 2007 IP
  3. eiso

    eiso Peon

    Messages:
    583
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Oh ofcourse - thank you, I needed that memory refreshment!
     
    eiso, Aug 2, 2007 IP