use strict; use warnings; my $matchStr = 'aabb'; my $match = "\xff?" . join ("\xff?", split '', $matchStr) . "\xff?"; my $str = "aa\xffbb"; if ($str =~ $match) { print "Matched"; } else { print "No match"; }