将 not^
运算符与反向引用结合使用时,为什么需要使用惰性匹配?看起来not
应该打破比赛。
例如:
<?php
preg_match('/(t)[^\1]*\1/', 'is this test ok', $matches);
echo $matches[0];
?>
将输出this test
,而不是this t
,尽管中间t
不匹配[^\1]
。我需要使用/(t)[^\1]*?\1/
来匹配this t
。
此外
preg_match('/t[^t]*t/', 'is this test ok', $matches);
发生了什么事,我误解了什么?