endsWith
  • 23 May 2023
  • Dark
    Light
  • PDF

endsWith

  • Dark
    Light
  • PDF

Article summary

endsWith Task Purpose

The endsWith task is used to search a given string to determine if a string (or specified sequence of characters) is included at the end. With this task method, you can also specify the number of characters in the string to be searched. A result of "True" indicates the string ends with the characters, and "False" if the characters are not found. Of note, this task does not change the value of the original string.

In contrast to endsWith, if you want to check if a string begins with the characters of a specified string, use the startsWith task.

Potential Use Case

You could potentially use this task if you want to check if a filename in a particular list endsWith a certain extension. For example, to check if filename.txt ends with .txt, you could use this task to perform a search on your list. A "True" result would tell you there is a filename that includes the extension; a "False" result would tell you that a filename with that extension was not found. Depending on the length of the list, you could also set the endsWith task to limit its search to only the beginning portion of your list.

Properties

Incoming Type Description
str String Required. The string to search.
searchString String Required. The string (or sequence) of characters to search for at the end of a given string.
length Number The length of the string that will be searched. If omitted, the default is to search the full length of the string.


Outgoing Type Description
result Boolean Returns true if the searchString is found, false otherwise.

Examples

Example 1

In this IAP example:

  • The input str variable is "Hello world, welcome to the universe."

  • The searchString value to search for is "universe."

  • In this example, the length is not specified, so the entire string will be searched.

  • The expected result will be "True", indicating that "universe." was found at the end of the string.

    endsWith-ex01

Example 2

In this IAP example:

  • The same input str is used, but the searchString value is "world".

  • The length parameter is specified. Only the first 11 characters of the string will be searched.

  • The expected result will return "True", indicating that "world" was found at end of the specified length.

    endsWith-ex02


Was this article helpful?

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.