fork(1) download
  1. <?php
  2. $regex = "~(?=(\b\w+\((?:\d+|(?1))\)))~";
  3. $string = "cos(t(2))+t(51)";
  4. $count = preg_match_all($regex,$string,$matches);
  5. print_r($matches[1]);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => cos(t(2))
    [1] => t(2)
    [2] => t(51)
)