0

i am trying to filter data using preg_match it seems to be correct and matching on view source code but when i run the code it gives no match found

here is my pattern

  /\<p\>(.*)\<center\>/

string is

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
           <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Untitled Document</title>
    </head>

    <body>
    <small>Photo courtesy of <a href="http://www.sxc.hu/photo/899943">hortongrou</a>           </small>
     </div>
     <p>I have developed theasional thriller.<br />
    <code> </code><br />


         <li><strong><a href="">Beginning Ubuntu Linux</a><img style="border:none !important; margin:0px !important;" src="" border="0" alt="" width="1" height="1" />, by Keir Thomas and Jaime Sicam.</strong> For those who like to transition from Windows to Linux, install Ubuntu Linux on one of yoto you.</li>
    </ol>
   <p class="alert">For more Linux books that I recommend, browse <a rel="nofollow" href="http://astore.amazon.com/thgest-20">The Geek Stuff bookstore at Amazon.</a></p>
    <p>There are several hundreds of books on Linux. <strong>What is your favorite Linux book that is not on this list?</strong><br />
  <code> </code><br />
    <em>If you like this article, please bookmark it on <strong>delicious and Stumble  it</strong>.</em></p>
         <center>
             <div style="margin-left:2px; margin-top:10px; margin-bottom:10px; ">

           <!-- AD BLOCK -->



      </body>

sachin
  • 727
  • 1
  • 5
  • 11

1 Answers1

0

By default . doesn’t match new lines. Try adding DOTALL (s) modifier like this /<p>(.*)<center>/s.

Jan Tojnar
  • 5,306
  • 3
  • 29
  • 49