startsWith

The startsWith task determines whether a string begins with another string and returns a boolean result of true or false.

Potential use case

Use this task to check the placement of a variable within a string of characters, or to determine if the string has missing or added characters.

Properties

IncomingTypeDescription
strStringRequired. The string to search.
searchStringStringRequired. The characters to search for at the start of str.
positionNumberOptional. The position in the string to begin searching for searchString. The first character is at position 0.
OutgoingTypeDescription
resultBooleantrue if the specified characters are found at the given position in the string; false otherwise.

Example 1

In this example:

  • The str is statically set to "Hello World".
  • The searchString is "W" and the position is 6.
  • The result returns true — the letter "W" is located at position six.
startsWith task with str Hello World, searchString W, and position 6 returning true
Outgoing result showing true

Example 2

This example is the same as Example 1, except the space between the words has been removed, making the string "HelloWorld".

startsWith task with str HelloWorld (no space), searchString W, and position 6

The result returns false — removing the space shifted "W" to position five, so it is no longer at position six.

Outgoing result showing false because W is now at position 5, not 6