How can I convert a string into a regular expression that matches itself in Perl?

前端 未结 5 1247
轮回少年
轮回少年 2021-01-13 20:43

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          


        
5条回答
  •  攒了一身酷
    2021-01-13 21:02

    To put Brad Gilbert's suggestion into an answer instead of a comment, you can use quotemeta function. All credit to him

提交回复
热议问题