PHP RegEx匹配到字符串结尾

Dav*_*iss 0 php regex

还在学习PHP Regex并有一个问题.

如果我的字符串是

Size : 93743 bytes Time elapsed (hh:mm:ss.ms): 00:00:00.156
Run Code Online (Sandbox Code Playgroud)

如何匹配之后出现的值(hh:mm:ss.ms):

00:00:00.156
Run Code Online (Sandbox Code Playgroud)

如果值后面有更多字符,我知道如何匹配,但之后没有任何字符,我不想包含大小信息.

提前致谢!

Jer*_*man 8

像这样:

<?php
$text = "Size : 93743 bytes Time elapsed (hh:mm:ss.ms): 00:00:00.156";

# match literal '(' followed by 'hh:mm:ss.ms' followed by literal ')'
# then ':' then zero or more whitespace characters ('\s')
# then, capture one or more characters in the group 0-9, '.', and ':'
# finally, eat zero or more whitespace characters and an end of line ('$')
if (preg_match('/\(hh:mm:ss.ms\):\s*([0-9.:]+)\s*$/', $text, $matches)) {
    echo "captured: {$matches[1]}\n";
}
?>
Run Code Online (Sandbox Code Playgroud)

这给出了:

captured: 00:00:00.156
Run Code Online (Sandbox Code Playgroud)