我有一個preg_match匹配特定模式,但它只是不匹配我試圖匹配的模式。我究竟做錯了什麼?使用preg_match來匹配這個特定模式
<?php
$string = "tell me about cats";
preg_match("~\b(?:tell me about|you know(?: of| about)?|what do you think(?: of| about)?|(?:what|who) is|(?:whats|whos)) ((?:[a-z]+){1,2})$~", $string, $match);
print_r($match);
?>
預期結果:
陣列(0 =>告訴我1 =>貓)
實際結果:
陣列()
https://regex101.com/r/cN8yO2/1在右手邊是什麼意思的一切解釋。 – Mike
有用的工具:[http://regexr.com/](http://regexr.com/) –