my $re = qr{^(\d+):}; my $data = '123: 45'; if ($data =~ $re) { print "Matched!"; }