my ($date, $year) = /(\w+\s+\d+),?\s+(\d{4})/;
print "$date, $year\n";
####
use warnings;
use strict;
while (){
if (my ($date, $year) =
/
( # start capture 1 ($date)
\w+ # word characters (month)
\s+ # space characters
\d+ # date chars
) # end capture 1
,? # comma or no comma,
\s+ # followed by possible whitespace
( # start capture 2 ($year)
\d{4} # four digits (year)
) # end capture 2
/x
)
{
print "$date, $year\n";
}
}
__DATA__
For the fiscal year ended Dec 31, 2015xxx
For the fiscal year ending December 31 2015
For the fiscal year ending December 31, 2015
####
Dec 31, 2015
December 31, 2015
December 31, 2015