如何仅返回匹配的部分?

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

How do I just get 'done', without the rest of the string?

From the documentation:

If matches is provided, then it is filled with the results of search. $matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on.

So:

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