Delimiter must not be alphanumeric or backslash and preg_match

后端 未结 7 1659
北荒
北荒 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:49

    You can also use T-Regx library which has automatic delimiters for you:

    $matches = pattern("My name is '(.*)' and im fine")->match($string1)->all();
    
                     // ↑ No delimiters needed 
    
    0 讨论(0)
提交回复
热议问题