use strict;
my $str = '04.march.2012 9:07:00
1999-03-22T05:06:07.000
20150420
14 мая 2015 08:30:43
1999 03 22T05:06:07.000+01:00
22.3.19 5:06:07
5:06:07 22.3.19
22. March 1999
1999-03-22 5:06:07.PD
March 22, 1999
March 22 1999
22/3/1999 5:06 AM
Mar 22 05:06:07 CET 1999
Mon Mar 22 05:06:07 CET 1999
Monday, March 22, 1999 5:06:07 o\'clock AM CET
22-Mar-1999 5:06:07 AM CET
22-Mar-1999 5:06:07 CET AM
1999-03-22 5.06.07.PD CET
Monday, March 22, 1999 5:06:07 AM CET';
my $regex = qr/(?:(?P<EngDate>[a-zA-Z]+\s)??(?P<Date0>(?<!\.)(?:\d{1,2}(?=[,\s.\/-])|\d{4}))\.??(?(1),?)(?P<d_sep>[\s\.\/-])?(?:(?P<Date1>[^\W\d_]+|\d{1,2})(?(3)(?P=d_sep)))?(?(1)(?:\s\d{2}:\d{2}:\d{2}\s\w+\s)?)(?P<Date2>\d{2}|\d{4})(?!\:|\.|\d))|(?:(?<!\d{2})(?P<Hours>[0-2]?\d)[\:\.](?P<Minutes>[0-6]\d)(?:[\:\.](?P<Seconds>[0-6]\d))?(?:[,\.](?P<SenodsFraction>\d{3}|\d{6}))?(?:\so'clock)?(?:(?:[\.,\s,\w+\s]?(?:(?P<Z>(?:[a-zA-Z]{3,5})|(?:[+-]\d\d?:?[0,3,4]?[0,5]?))|(?P<s>PD|AM|PM|am|pm)))+)?)/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html