// short version
$re = '/(?:(?<!-------[A-Z][a-z][a-z] \d\d-------).)*+$/s';
// long commented version
$re = '/ # free-spacing mode regex to match all data after last ---date--- line
(?: # non-capture group for star quantifier
(?<! # at a position that does not follow
-------[A-Z][a-z][a-z][ ]\d\d------- # <-this,
). # match any one character
)*+ # and do this any number of times
$ # up until the end of the string
/sx';
if (preg_match($re, $text, $matches)) {
$result = $matches[0];
} else {
$result = "";
}
Edit 2009-09-06: This regex has a minor problem - see following post for explanation and fix...
Last edited by ridgerunner on Sun Sep 06, 2009 10:06 am, edited 1 time in total.
Actually, the regex in my previous post has a problem when the file has "\r\n" line terminations. It matches a "\n" as the first character. The following regex fixes this problem by explicitly matching the first character following the date line.
// short version
$re = '/(?<=-------[A-Z][a-z][a-z] \d\d-------\r\n).(?:(?<!-------[A-Z][a-z][a-z] \d\d-------\r\n).)*+$/s';
// long commented version
$re = '/
# free-spacing mode regex to match all data after last ---date--- line
(?<= # at a position following
-------[A-Z][a-z][a-z][ ]\d\d-------\r\n # <-this
). # grab the first character
(?: # then start group to grab the rest
(?<! # at a position that does not follow
-------[A-Z][a-z][a-z][ ]\d\d-------\r\n # <-this,
). # match any one character
)*+ # and do this any number of times
$ # up until the end of the string
/sx';
if (preg_match($re, $text, $matches)) {
$result = $matches[0];
} else {
$result = "";
}