positionOf

Calculates the position of a substring and returns its index value. Note that the first character in a string is position "0", the second is position "1", etc. If the substring is not found within the specified string, this method returns "-1".

Syntax:

$[ScriptVariable]::positionOf(String str)

Parameters:

str (String): the substring for which you want to calculate an index value.

Example:

The following example illustrates how to use the positionOf variable method to return a Device name from within a variable containing the Device's target name:

$recipientTargetName = "bsmith|Home Email"

$position = $recipientTargetName::positionOf("|")

$deviceName = $recipientTargetName::substring($position + 1)

print($deviceName)

Output:

Home Email