I am having trouble refining a regex query. I am using it in a PowerShell script to convert a camel-case group name to "regular text". e.g. TestGroup to Test Group. I have been using the following code to do this:
$GroupNameProper = $GroupName -creplace "(\B[A-Z])", ' $1'
In most cases this works, unless the "proper" name has two capitals in a row. For example, HRSecretary becomes H R Secretary, rather then the intended HR Secretary. I need to place a space between capitalized letters ONLY if the next character is lower-case.
Unfortunately, my experience with Regex is too limited. The answer is probably obvious, but I'm just not getting it...