Delimiter must not be alphanumeric or backslash and preg_match

后端 未结 7 1735
北荒
北荒 2020-11-22 10:20

I have this code :

$string1 = \"My name is \'Kate\' and im fine\"; 
$pattern = \"My name is \'(.*)\' and im fine\"; 
preg_match($pattern , $string1, $matches         


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 10:29

    You need a delimiter for your pattern. It should be added at the start and end of the pattern like so:

    $pattern = "/My name is '(.*)' and im fine/";  // With / as a delimeter 
    

提交回复
热议问题