Difference between revisions of "String"

From GiderosMobile
m (→‎Description: fixed some html tags)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
 
<languages />
 
<languages />
 +
 
<!-- GIDEROSOBJ:string -->
 
<!-- GIDEROSOBJ:string -->
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
+
 
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]
 +
<br/>
 +
 
 +
'''<translate>Available since</translate>:''' Gideros 2011.6
 +
<br/>
 +
 
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
<translate>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.  
+
<translate>
 +
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.  
 +
</translate>
 +
 
 +
<translate>
 +
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).
 +
</translate>
  
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).  
+
<translate>
 +
The string library assumes one-byte character encodings.
 +
</translate>
  
The string library assumes one-byte character encodings.</translate>
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|

Revision as of 22:52, 17 June 2019



Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png

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

Events

Constants