endWith

Returns true if the first string element in the variable ends with the specified character sequence; otherwise, returns false. Note that the result will be true if the argument is an empty string, or is equal to this string object as determined by the equality operator.

Note: The endWith string method is case sensitive.

Syntax:

$[ScriptVariable]::endWith(String suffix)

Parameters:

suffix (String): the character sequence to compare with the end of the string variable.

Example:

The following example illustrates the syntax for the endWith string method:

$str = "Hello World"

$end = $str::endWith("World")

print($end)

Output:

true