in reply to REGEX for date

Does the following work by chance?

my ($date, $year) = /(\w+\s+\d+),?\s+(\d{4})/; print "$date, $year\n";

Explanation inside an example:

use warnings; use strict; while (<DATA>){ 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

Output:

Dec 31, 2015 December 31, 2015 December 31, 2015

That regex may work, but it has the potential for significant failure rates. Unless you know your data very well, test the results extensively.