<?php $str = 'Henry J Doe'; $repl = preg_replace('/([A-Z])(?=\s|$)/', '\1.', $str); echo $repl . "\n";?>
Standard input is empty
Henry J. Doe
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!