title: Match & Extract Multi-line Pattern In File
body: <p>I made a Bash script to download this page <a href="http://php.net/downloads.php" rel="nofollow">http://php.net/downloads.php</a> and then search for the first occurrence of the latest PHP filename, version and MD5sum. Right now I have it working but broken up into two different sed commands. When I try to put the regexps into a single one it wont match. I believe it has to do with the newlines present.<br>
  How do I go about using one single sed pattern where I get all three matches in either an array (preferred) or seperated by spaces.  </p>
  
  <p>Btw, it does not have to be sed. I just want something where the system that the script will be run on will likely work, so no perl for instance.</p>
  
  <pre><code>wget -q http://php.net/downloads.php
  FILE_INFO=$(sed -nr "s/.*(php-([0-9\.]+)\.tar\.bz2).*/\1 \2/p;T;q" downloads.php)
  MD5SUM=$(sed -nr "s/.*md5: ([0-9a-f]{32}).*/\1/p;T;q" downloads.php)
  
  echo $FILE_INFO
  echo $MD5SUM</code></pre>
  
  <p>These are the two lines from the file in question and it needs to extract the info from:</p>
  
  <pre><code>  &lt;a href="/get/php-5.4.5.tar.bz2/from/a/mirror"&gt;PHP 5.4.5 (tar.bz2)&lt;/a&gt; [10,754Kb] -  19 July 2012&lt;br /&gt;
    &lt;span class="md5sum"&gt;md5: ffcc7f4dcf2b79d667fe0c110e6cb724&lt;/span&gt;</code></pre>