title: PHP preg_match to grab text in between two HTML tags
body: <p>I'm trying to use preg_match to grab the text in between two HTML tags.</p>
  
  <p>Here's a simplified version of my code:</p>
  
  <pre><code> $sPattern = "/&lt;li class=\"sample\"&gt;(.*?)&lt;\/li&gt;/s";
   $sText = "blah blah blah &lt;li class=\"sample\"&gt;hello world!&lt;/li&gt; blah blah blah";
   preg_match($sPattern,$sText,$aMatch);
   echo '&lt;pre&gt;'.print_r($aMatch).'&lt;/pre&gt;';
  </code></pre>
  
  <p>However, when I run this code, I get the full HTML string returned:</p>
  
  <pre><code>&lt;li class=\"sample\"&gt;hello world!&lt;/li&gt;
  </code></pre>
  
  <p>Does anyone know what changes I need to make to my regular expression?</p>
  
  <p>Note: I'm aware of other ways to parse data from an HTML page. For various reasons, DOMDocument and DOMXPath are not an option--I'm sticking with RegEx.</p>