Skip to main content

Check if a string ends with (string.ends_with)

Declaration​

ok = string.ends_with(text, suffix[, len])

Parameters​

  • text
    string.
  • suffix
    string.
  • len
    integer, optional. Length to consider for search. Default: length of text.

Returns​

  • ok
    boolean.

Description​

Check whether text ends with suffix.
Available in versions after 2025-03-13

Example​

nLog(string.ends_with('Hello, XXTouch', 'XXTouch')) -- true
nLog(string.ends_with('Hello, XXTouch', 'ello', 5)) -- true

Note: Uses function outside of this chapter: nLog