1
2
3
4
5
6
7
8
9
my $str = '200908';
my $ra = Regexp::Assemble->new;
$ra->insert(qw((^2005..2008)(01..12)));
if ($ra->match($str)){
print "ja\n";
}else{
print "nein\n";
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#/usr/bin/perl use strict; use warnings; use Regexp::Assemble; my $str = '200908'; my $ra = Regexp::Assemble->new; for my $y (5..8) { for my $m (1..12) { my $datum=sprintf('20%02u%02u',$y,$m); $ra->add($datum); } } print $ra->re()."\n"; if ($ra->match($str)){ print "ja\n"; }else{ print "nein\n"; }
my $regex = qr{^(20[1-9][0-9])(0[1-9]|1[012])};