Utf8.find

From GiderosMobile
Revision as of 15:32, 13 July 2023 by Hgy29 (talk | contribs) (Text replacement - "<source" to "<syntaxhighlight")


Available since: Gideros 2016.06
Class: utf8

Description

Looks for the first match of pattern in the string s. If it finds a match, then find returns the indices of s where this occurrence starts and ends; otherwise, it returns nil. A third, optional numerical argument init specifies where to start the search; its default value is 1 and can be negative. A value of true as a fourth, optional argument plain turns off the pattern matching facilities, so the function does a plain "find substring" operation, with no characters in pattern being considered magic. Note that if plain is given, then init must be given as well. If the pattern has captures, then in a successful match the captured values are also returned, after the two indices. <syntaxhighlight lang="lua"> (numbers) = utf8.find(s,pattern,init,plain) </source>

Parameters

s: (string)
pattern: (string)
init: (number) optional
plain: (boolean) optional

Return values

Returns (numbers) the indices of s where this occurrence starts and ends; otherwise, it returns nil