Insert Spaces Between Capital Letters in a String Posted on May 18, 2009 by Troy Works well with formatting output of form field keys. preg_replace(‘/(\w+)([A-Z])/U’, ‘\\1 \\2′, $string);