I have a function which is detecting and unmerging two words i.e.
HelloWord
after function will become
Hello World
the problem is it will do same to iPhone -> i Phone which is not good, is there a way to replace only if first word is longer than 1
here is my current function (regex):
function unseparateWords($string)
{
$CapRegX = '/(\B[A-Z])(?=[a-z])|(?<=[a-z])([A-Z])/sm';
$RepStr = ' $1$2';
return preg_replace($CapRegX,$RepStr,$string);
}
thanks for help.
cheers, /Marcin
You could search for the position between a lowercase and an uppercase character
and replace this "zero-length string" with a space.
In PHP: