You need to use delimiters in your regular expression - not alphanumeric as indicated in the error message:
$line = preg_replace("/ !([AZ])/", " $1", $line);
Note the / characters at the beginning and end of the regular expression string.
It should not be / - you can use # or even ! but if you use ! you will need to avoid ! char inside regex itself.
Aleks G
source share