- preg_match: documentation ( source)
<?php
$strings = [
'$hey()',
'$hey->hi()',
'$hey(\'hi\')',
'$hey moretext()'
];
foreach ($strings as $string) {
if (preg_match('~^\$\w+\([^)]*\)$~', $string)) {
echo $string . "\n";
}
}