Difference between revisions of "String"

From GiderosMobile
Line 11: Line 11:
 
| style="width: 50%;"|
 
| style="width: 50%;"|
 
=== Methods ===
 
=== Methods ===
[[string.byte]] - returns numerical code, nil if index out of range, default i=1<br/>
+
[[string.byte]] {{<translate>returns numerical code, nil if index out of range, default i=1</translate>}}<br/>
[[string.char]] - returns a string built from 0 or more integers<br/>
+
[[string.char]] {{<translate>returns a string built from 0 or more integers</translate>}}<br/>
[[string.dump]] - returns binary representation of function, used with loadstring<br/>
+
[[string.dump]] {{<translate>returns binary representation of function, used with loadstring</translate>}}<br/>
[[string.find]] - matches pattern in s, returns start,end indices, else nil<br/>
+
[[string.find]] {{<translate>matches pattern in s, returns start,end indices, else nil</translate>}}<br/>
[[string.format]] - returns formatted string, printf-style<br/>
+
[[string.format]] {{<translate>returns formatted string, printf-style</translate>}}<br/>
[[string.gmatch]] - returns iterator function that returns next captures from pattern pat on s<br/>
+
[[string.gmatch]] {{<translate>returns iterator function that returns next captures from pattern pat on s</translate>}}<br/>
[[string.gsub]] - returns copy of s with pat replaced by repl, and substitutions made<br/>
+
[[string.gsub]] {{<translate>returns copy of s with pat replaced by repl, and substitutions made</translate>}}<br/>
[[string.len]] - returns string length<br/>
+
[[string.len]] {{<translate>returns string length</translate>}}<br/>
[[string.lower]] - returns string with letters in lower case<br/>
+
[[string.lower]] {{<translate>returns string with letters in lower case</translate>}}<br/>
[[string.match]] - Searches a string for a pattern.<br/>
+
[[string.match]] {{<translate>Searches a string for a pattern.</translate>}}<br/>
[[string.rep]] - returns string with n copies of string s<br/>
+
[[string.rep]] {{<translate>returns string with n copies of string s</translate>}}<br/>
[[string.sub]] - returns substring from index i to j of s, default j=-1(string length-<br/>
+
[[string.sub]] {{<translate>returns substring from index i to j of s, default j=-1(string length-</translate>}}<br/>
[[string.upper]] - returns string with letters in upper case<br/>
+
[[string.upper]] {{<translate>returns string with letters in upper case</translate>}}<br/>
 
| style="width: 50%;"|
 
| style="width: 50%;"|
 
=== Events ===
 
=== Events ===
 
=== Constants ===
 
=== Constants ===
 
|}
 
|}

Revision as of 14:18, 23 August 2018

Supported platforms: android, ios, mac, pc
Available since: Gideros 2011.6

Description

This library provides generic functions for string manipulation, such as finding and extracting substrings, and pattern matching. When indexing a string in Lua, the first character is at position 1 (not at 0, as in C). Indices are allowed to be negative and are interpreted as indexing backwards, from the end of the string. Thus, the last character is at position -1, and so on.

The string library provides all its functions inside the table string. It also sets a metatable for strings where the __index field points to the string table. Therefore, you can use the string functions in object-oriented style. For instance, string.byte(s, i) can be written as s:byte(i). 
The string library assumes one-byte character encodings.

Methods

string.byte Template:Returns numerical code, nil if index out of range, default i=1
string.char Template:Returns a string built from 0 or more integers
string.dump Template:Returns binary representation of function, used with loadstring
string.find Template:Matches pattern in s, returns start,end indices, else nil
string.format Template:Returns formatted string, printf-style
string.gmatch Template:Returns iterator function that returns next captures from pattern pat on s
string.gsub Template:Returns copy of s with pat replaced by repl, and substitutions made
string.len Template:Returns string length
string.lower Template:Returns string with letters in lower case
string.match Template:Searches a string for a pattern.
string.rep Template:Returns string with n copies of string s
string.sub Template:Returns substring from index i to j of s, default j=-1(string length-
string.upper Template:Returns string with letters in upper case

Events

Constants