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
There is a function for that quotemeta.
quotemeta EXPR
Returns the value ofEXPRwith all non-"word" characters backslashed. (That is, all characters not matching/[A-Za-z_0-9]/will be preceded by a backslash in the returned string, regardless of any locale settings.) This is the internal function implementing the\Qescape in double-quoted strings.If
EXPRis omitted, uses$_.