Regex to capture everything before first optional string
Try this: (.*?)(?:EFG|$)
This will match any character (as few as possible) until it finds EFG.
Another way to do it:
$str = 'Q$TQ@#%GEFGw35hqb';
$res = preg_split('/EFG/', $str);
print_r($res);
You can use
'/(.*?)(?=EFG|$)/'