my $str = "06 03 01 0f 0e 0b"; if ($str=~ /06 03 01 [[:xdigit:]]{2} [[:xdigit:]]{2} 0b/){ print "hi"; }