[GRLUG] a little regex help

topher at t1kdevelopment.com topher at t1kdevelopment.com
Sun Jun 13 19:07:26 UTC 2010


> Assuming $data contains the output above,
>
> $data = str_replace("\n", "", $data);    // put all on one line to make regex 
> easier
> preg_match_all("/Duration: (.+)\./U", $data, $matches);     // using ungreedy 
> flag to stop at first (.)
> echo $matches[1][0];
>
> Roger

That worked wonderfully, thanks.  The thing I spent the most time on was 
actually getting the output.  shell_exec worked where none of the other 
exec functions did.

Topher


More information about the grlug mailing list