October 2017
Intermediate to advanced
440 pages
11h 47m
English
The Trim method, by default, removes all white space (spaces, tabs, and line breaks) from the beginning and end of a string. For example:
$string = "
This string has leading and trailing white space "
$string.Trim()
The TrimStart and TrimEnd methods limit their operation to either the start or end of the string.
Each of the methods accepts a list of characters to trim. For example:
$string = '*__This string is surrounded by clutter.--#'
$string.Trim('*_-#')
The Trim method does not remove a string from the end of another. The string supplied in the previous example ('*_-#') is treated as an array. This can be seen in the definition of the method:
PS> 'string'.TrimOverloadDefinitions ------------------- string ...
Read now
Unlock full access