Skip to main content

Check if a string starts with (string.starts_with)

Declaration

ok = string.starts_with(text, prefix[, pos])

Parameters

  • text
    string.
  • prefix
    string.
  • pos
    integer, optional. Start position, default 1.

Returns

  • ok
    boolean.

Description

Check whether text starts with prefix.
Available in versions after 2025-03-13

Example

nLog(string.starts_with('Hello, XXTouch', 'Hello')) -- true
nLog(string.starts_with('Hello, XXTouch', 'ello', 2)) -- true

Note: Uses function outside of this chapter: nLog