endsWith

Syntax expression1 endsWith expression2

Action Evaluates both expressions as strings, and determines whether the result of expression1 ends with the result of expression2. If expression1 produces a list, expression2 is evaluated as a list and the comparison is done on a list basis rather than as

strings.

Examples "The quick brown fox" endsWith "The"

   » false

file.fileFromPath (f) endsWith " Backup"

   » true

The expression would return true for files named "ToDo Backup" and "Report Backup", but false for "run backup" since the lower case 'b' doesn't match the upper-case 'B'. Note that we don't really need to call file.fileFromPath here, since the file name is
at the end of the path anyway.

1234 endsWith 34

   » true

The numbers are converted to strings for this operation.

{1, 2, 3} endsWith 3

   » true

The number 3 is converted to a list, and the comparison results in true.

Notes The endsWith operator is case-sensitive; upper-case characters do not match lower-case ones.

See Also beginsWith

contains

string.hasSuffix

string.patternMatch

Discuss