$str = "My Report Title";
$strPad = $str.PadLeft(20) + ".";
Write-Host $strPad;
The output looks like this:
$strPad = $str.PadRight(20) + ".";
Write-Host $strPad;
The output looks like this:
My Report Title .
Here you can clearly see the 5 spaces before the period. ;-)
If you want to pad with something other than spaces, you can simply supply the second, optional parameter to PadLeft() or PadRight() specifying the character to be used for padding e.g.
Write-Host $strPad;
The output looks like this:
If you want to pad with something other than spaces, you can simply supply the second, optional parameter to PadLeft() or PadRight() specifying the character to be used for padding e.g.
$strPad = $str.PadRight(20, "$") + ".";
Write-Host $strPad;
The output looks like this:
C
No comments:
Post a Comment
Comments are moderated only for the purpose of keeping pesky spammers at bay.