title: Perl: how to parse Date from a string
body: <p>I need to write a regular expression that extracts Date from a string.</p>
  
  <p>Here is a string examples:</p>
  
  <p>Date: Tue, 11 Feb 2014 11:01:57 +0100 (CET)</p>
  
  <p>Date: Tue, 9 Feb 2014 11:01:57 +0100 (CET)</p>
  
  <p>Here is what I tried:</p>
  
  <pre><code>$str =~ /Date.+(\d+\s[a-zA-Z]{3}\s\d{4}).+(CET)/;
  print $1;
  $str =~ /Date.+(\d{1,2}\s[a-zA-Z]{3}\s\d{4}).+(CET)/;
  print $1
  </code></pre>
  
  <p>Both fail when I have two digit day. I have tried different variations but unsuccessfully.</p>
  
  <p>I was able to make it work with following:</p>
  
  <pre><code>$str =~ /Date.+(\s\d+\s[a-zA-Z]{3}\s\d{4}).+(CET)/;
  my $date = $1;
  $date =~ s/^\s//;
  </code></pre>
  
  <p>Unfortunately, this is not a pretty solution. I am sure there is a way to make it happen in regex I just cannot find it.</p>
  
  <p>Please advise.</p>
  
  <p>Thank you,</p>
  
  <p>-Andrey</p>