use Regexp::Simple; my $re = qr{ start_of_line literal("1998/10/08") optional( whitespace ) literal("[") remember( many( any( ":", digit ) ) ) non_digit }; if ('1998/10/08 [11:10]' =~ m/$re/) { print "Found a match at time $1!\n"; }