Delimiter must not be alphanumeric or backslash and preg_match

后端 未结 7 1736
北荒
北荒 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:32

    The pattern must have delimiters. Delimiters can be a forward slash (/) or any non alphanumeric characters(#,$,*,...). Examples

    $pattern = "/My name is '(.*)' and im fine/"; 
    $pattern = "#My name is '(.*)' and im fine#";
    $pattern = "@My name is '(.*)' and im fine@";  
    

提交回复
热议问题