2011-06-11 88 views

回答

5

documentation

如果提供的比赛,则充满了搜索的结果。 $matches[0]将包含匹配完整模式的文本,$matches[1]将具有匹配第一个捕获的括号内子模式的文本,依此类推。

所以:

$string='this dog is done'; 
preg_match('/^this dog is ([^.]+)/',$string,$m); 
echo $m[1]."\n";