Detect exact string value of scalar in regex matching

后端 未结 1 1949
生来不讨喜
生来不讨喜 2020-12-22 01:16

Say I have $foo = \"bar.baz\"

I want to use the scalar $foo to find strings that contain \"bar.baz\" (anywhere in the string), but not the regex-evalut

相关标签:
1条回答
  • 2020-12-22 02:08

    Pick one:

    1. $foo = quotemeta("bar.baz");
    2. if ($other =~ m/\Q$foo/)

    (Both are actually the same thing, just done at different times.)

    0 讨论(0)
提交回复
热议问题