How to use ^/$ if it's already used as a delimiter for regex in PHP?

后端 未结 2 1838
猫巷女王i
猫巷女王i 2021-01-22 02:37
$regex = \'$....$\'

$regex = \'^...^\'

In the above two cases,how to use ^/$ to match the beginning/end of a string?

2条回答
  •  情书的邮戳
    2021-01-22 03:06

    just do escaping ?

    $str='^...^';
    preg_match("/^\^.*\^$/",$str,$matches);
    print_r($matches);
    

提交回复
热议问题