Utf8.gmatch

From Multi Theft Auto: Wiki
Revision as of 02:43, 15 February 2016 by Necktrox (talk | contribs) (Created page with "__NOTOC__ {{Shared function}} This function returns a pattern finding iterator for UTF-8 strings. The iterator will search through the string '''input''' looking for instance...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function returns a pattern finding iterator for UTF-8 strings. The iterator will search through the string input looking for instances of the pattern you passed. For more information on iterators read the ForTutorial and IteratorsTutorial.

Syntax

iterator utf8.gmatch ( string input, string pattern )

Required Arguments

  • input: A string character sequence
  • pattern: A string match pattern

Returns

Returns an function for iterations on the input string by using the passed pattern string.

Example

Click to collapse [-]
Server

This example prints every word in the UTF-8 string

for word in utf8.gmatch( "Как вас зовут?", "%a+" ) do 
    print( word )
end

Output:

Как
вас
зовут

See Also