I'n new to Powershell so apologies if this is an obvious question. I have the following function which delimits a string:
[int[]]$rec02 = 3,2,1,4,3,3,5,5,6,1,19,45,2,3,50
function delimitString([string]$text, [int[]]$arrDelims)
{
[string]$out;
[int]$total=0;
foreach($d in $arrDelims)
{
$out += $text.substring($total,$d)+",";
$total +=$d;
}
$out += $text.substring($total,$text.length-$total)+",";
return $out;
}
When this is called as follows: delimitString "gjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjlllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffllllllllll" $rec02
How can I suppress/why are there new line/carriage returns at the start/end of the output?
gjj,jj,j,jjjj,jjj,jjj,jjjjj,jjjjj,jjjjjj,j,jjjjlllllllllllllll,llllllllllllllll lllllllllllllllllllllllllllll,ll,lll,llllllllllllllllllllllllllffffffffffffffff ffffffff,ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff fffffffffffffffffffffffffffffffffffffffffllllllllll,
I eventually write this to a file and therefore I am ending up with blank lines in the output.