EndsWith (String function)

From m204wiki
Revision as of 03:35, 21 February 2020 by Alex (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Is the end string the terminal substring of the method object string? (String class)

[Introduced in Model 204 7.8 βeta]

EndsWith can be used to check whether one string ends with another.

Syntax

%boolean = string:EndsWith( endString)

Syntax terms

%boolean The Boolean result is True if endString is the same as the terminal characters of string.
string The method object string whose terminal characters are compared with endString.
endStringA string which is compared with the terminal characters of string.

Usage notes

  • If endString is a null (zero-length) string, EndsWith returns True.
  • endString must be longer than 255 bytes. A longer endString results in request cancellation.

Examples

The following fragment:

printText {~= "abcdefg":endsWith("")} printText {~= "abcdefg":endsWith("abcdefg")} printText {~= "abcdefg":endsWith("xabcdefg")} printText {~= "abcdefg":endsWith("def")}

produces the following output:

"abcdefg":endsWith("")= True "abcdefg":endsWith("abcdefg")= True "abcdefg":endsWith("xabcdefg")= False "abcdefg":endsWith("def")= False

See also