$re = '/modified:\s+((?>\w+\/?)+)[^)\v]*\)/';
$str = ' modified: apps/aaaaaa/bbbbbb/ccccff
modified: apps/ami (new commits)
modified: apps/assess (new commits)
modified: apps/ees121 (new commits)
modified: apps/energy_bourse (new commits)
modified: apps/gis (new commits)
modified: apps/hse (new commits)
modified: apps/aa/aaa/a/bb/b/bb/bc/c22/s/df/s/
modified: apps/management (new commits)
modified: apps/payesh (new commits)
modified: external_apps (modified content)
modified: modules/esb_server (new commits)
modified: modules/formbuilder (new commits, modified content)
modified: modules/reporting (new commits)
modified: modules/safir (new commits)
modified: modules/workflow (new commits)
modified: vendor/raya_framework/client (new commits)
modified: vendor/raya_framework/core (new commits)';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php