How can I insert a period after any capitalized single letter that is not already followed by a capital letter according to the following rules:

1. It is the followed by a space; or
2. It is followed by another capitalized letter; or
3. It the last letter in the string and preceded by a space or capitalized letter

Sample Inputs/Outputs:

`Patrick TJ Stephens` becomes `Patrick T.J. Stephens`  

`TJ Stephens` becomes `T.J. Stephens`  

`TJ Stephens QC` becomes `T.J. Stephens Q.C.`  

`Marissa C J Gilbert` becomes `Marissa C. J. Gilbert`  

`Marissa C Gilbert` becomes `Marissa C. Gilbert`  

`C Marissa Gilbert` becomes `C. Marissa Gilbert`  

`Marissa Gilbert C` becomes `Marissa Gilbert C.`

I've been using:

```
$str = preg_replace( '/([A-Z])(?=\s|$)/', '\1.', $str );

```

Unfortunately, it turns `Patrick TJ Stephens` into `Patrick TJ. Stephens` instead of `Patrick T.J. Stephens`.