Remove the ?
in .*?
, you don't want it to be lazy.
Adding a ?
to a quantifier makes it lazy, which roughly means that it will match the least amount possible while the overall regex still returning a match.
You have no anchor at the end, so when .*?
matches the least amount possible (because of laziness), it matches, well, nothing. Your whole regex only matches The
.
This should do the trick
preg_replace('/^(the|an?) (.*)/i', '$2, $1', 'The Final Book Title');