$string = 'My Test Data'; $regex = '(?i)\btest\b'; print $string =~ m/$regex/ ? "Match\n" : "No match\n";