The startsWith task is used to determine whether or not a string begins with another string. The task returns a boolean value of True or False based on whether the string starts with the characters of a specified string.
Potential Use Case
Use this task to check the placement of a variable within a string of characters. You could use startsWith to determine if the string has missing or added characters.
Input and output parameters are shown below.
||String||Required. The string to be searched.|
||String||Required. The characters to be searched for at the start of
||Number||The position in the given string to begin searching for the
||Boolean||True if the specified characters are found at the beginning of the string; false otherwise.|
In this IAP example, the
strvariable is statically set as "Hello World".
searchStringto find is "W" and the
positionto begin searching is at character "6". Remember, the location of the first character in a string is always 0, the second character 1, and so on.
resultof this task returns True; the "W" is located in the number "6" character
The next IAP example is the same as the first except the space between the words "HelloWorld" has been removed.
resultreturns False since the "W" is now located in
position"5" due to the removal of the space.