How can I convert a string to a regular expression that matches itself in Perl?
I have a set of strings like these:
Enter your selection: Enter Code
As Brad Gilbert commented use quotemeta:
my $regex = qr/^\Q$string\E$/;
or
my $quoted = quotemeta $string; my $regex2 = qr/^$quoted$/;