startsWith
  • Dark
    Light
  • PDF

startsWith

  • Dark
    Light
  • PDF

startsWith Task Purpose

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.

Properties

Input and output parameters are shown below.

Incoming Type Description
str String Required. The string to be searched.
searchString String Required. The characters to be searched for at the start of str.
position Number The position in the given string to begin searching for the searchString.


Outgoing Type Description
result Boolean True if the specified characters are found at the beginning of the string; false otherwise.

Example 1

  • In this IAP example, the str variable is statically set as "Hello World".

  • The searchString to find is "W" and the position to 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.

    startsWith-01

  • The result of this task returns True; the "W" is located in the number "6" character position.

    startsWithTrue-02

Example 2

  • The next IAP example is the same as the first except the space between the words "HelloWorld" has been removed.

    startsWith-03

  • The result returns False since the "W" is now located in position "5" due to the removal of the space.

    startsWithFalse-04


What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.