m#this#; s!foo!bar!; s{this}; m!word/word/word/word! #### my $sting = 'all the metachars |+*?(){}-[]^$. '; $regex_safe = quotemeta $string; print "We have a match" if m/$regex_safe/; # alternatively we can use \Q (begin quotemeta) and \E (end qm) print "We have a match" if m/\Q$string\E/; # to do what you want perhaps you might use... m!(?:[\w ]+/){3}[\w ]+!;