分离拥挤的单词

实现效果:
  

实现代码:

filter Split-UpperChars
{
   param( [Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$str)
   $offset=0;$s=$str
   1..$str.length|%{
   if($str[$_] -cmatch "[A-Z]"){
   $s=$s.Insert(($_+$offset),' ')
   $offset+=1}};return $s
}

>2

"Address Bar" -creplace "[A-Z]"," `$0"

>3

regex]::Replace("AddressBar","[A-Z]",{param($x) " "+$x.value})
原文地址:https://www.cnblogs.com/feiyucha/p/10579492.html