Difference between revisions of "String"

From GiderosMobile
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
<languages />
 
 
 
<!-- GIDEROSOBJ:string -->
 
<!-- GIDEROSOBJ:string -->
 +
'''Supported platforms:''' [[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/>
 +
'''Available since:''' 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]]
+
=== Description ===
<br/>
+
This library provides generic functions for string manipulation, such as finding and extracting substrings, and pattern matching.
 
 
'''<translate>Available since</translate>:''' Gideros 2011.6
 
<br/>
 
  
=== <translate>Description</translate> ===
+
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).
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>
 
  
<translate>
+
'''The string library assumes one-byte character encodings.'''
The string library assumes one-byte character encodings.
 
</translate>
 
  
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
=== Methods ===
[[Special:MyLanguage/string.byte|string.byte]] ''<translate>returns numerical code, nil if index out of range, default i=1</translate>''<br/><!-- GIDEROSMTD:string.byte(s,i,j) returns numerical code, nil if index out of range, default i=1 -->
+
[[string.byte]] ''returns numerical code''<br/><!--GIDEROSMTD:string.byte(s,i,j) returns numerical code, nil if index out of range, default i=1-->
[[Special:MyLanguage/string.char|string.char]] ''<translate>returns a string built from 0 or more integers</translate>''<br/><!-- GIDEROSMTD:string.char(i1,i2,...) returns a string built from 0 or more integers -->
+
[[string.char]] ''returns a string built from 0 or more integers''<br/><!--GIDEROSMTD:string.char(i1,i2,...) returns a string built from 0 or more integers-->
[[Special:MyLanguage/string.dump|string.dump]] ''<translate>returns binary representation of function, used with loadstring</translate>''<br/><!-- GIDEROSMTD:string.dump(function) returns binary representation of function, used with loadstring -->
+
[[string.dump]] ''returns binary representation of function, used with loadstring''<br/><!--GIDEROSMTD:string.dump(function) returns binary representation of function, used with loadstring-->
[[Special:MyLanguage/string.find|string.find]] ''<translate>matches pattern in s, returns start,end indices, else nil</translate>''<br/><!-- GIDEROSMTD:string.find(s,pattern,init,plain) matches pattern in s, returns start,end indices, else nil -->
+
[[string.find]] ''matches pattern in s, returns start,end indices, else nil''<br/><!--GIDEROSMTD:string.find(s,pattern,init,plain) matches pattern in s, returns start,end indices, else nil-->
[[Special:MyLanguage/string.format|string.format]] ''<translate>returns formatted string, printf-style</translate>''<br/><!-- GIDEROSMTD:string.format(formatstring,e1,e2,...) returns formatted string, printf-style -->
+
[[string.format]] ''returns formatted string, printf-style''<br/><!--GIDEROSMTD:string.format(formatstring,e1,e2,...) returns formatted string, printf-style-->
[[Special:MyLanguage/string.gmatch|string.gmatch]] ''<translate>returns iterator function that returns next captures from pattern pat on s</translate>''<br/><!-- GIDEROSMTD:string.gmatch(s,pat) returns iterator function that returns next captures from pattern pat on s -->
+
[[string.gmatch]] ''returns iterator function that returns next captures from pattern pat on s''<br/><!--GIDEROSMTD:string.gmatch(s,pat) returns iterator function that returns next captures from pattern pat on s-->
[[Special:MyLanguage/string.gsub|string.gsub]] ''<translate>returns copy of s with pat replaced by repl, and substitutions made</translate>''<br/><!-- GIDEROSMTD:string.gsub(s,pat,repl,n) returns copy of s with pat replaced by repl, and substitutions made -->
+
[[string.gsub]] ''returns copy of s with pat replaced by repl, and substitutions made''<br/><!--GIDEROSMTD:string.gsub(s,pat,repl,n) returns copy of s with pat replaced by repl, and substitutions made-->
[[Special:MyLanguage/string.len|string.len]] ''<translate>returns string length</translate>''<br/><!-- GIDEROSMTD:string.len(s) returns string length -->
+
[[string.len]] ''returns string length''<br/><!--GIDEROSMTD:string.len(s) returns string length-->
[[Special:MyLanguage/string.lower|string.lower]] ''<translate>returns string with letters in lower case</translate>''<br/><!-- GIDEROSMTD:string.lower(s) returns string with letters in lower case -->
+
[[string.lower]] ''returns string with letters in lower case''<br/><!--GIDEROSMTD:string.lower(s) returns string with letters in lower case-->
[[Special:MyLanguage/string.match|string.match]] ''<translate>Searches a string for a pattern.</translate>''<br/><!-- GIDEROSMTD:string.match(string,pattern) Searches a string for a pattern. -->
+
[[string.match]] ''searches a string for a pattern''<br/><!--GIDEROSMTD:string.match(string,pattern) searches a string for a pattern-->
[[Special:MyLanguage/string.rep|string.rep]] ''<translate>returns string with n copies of string s</translate>''<br/><!-- GIDEROSMTD:string.rep(s,n) returns string with n copies of string s -->
+
[[string.rep]] ''returns string with n copies of string s''<br/><!--GIDEROSMTD:string.rep(s,n) returns string with n copies of string s-->
[[Special:MyLanguage/string.sub|string.sub]] ''<translate>returns substring from index i to j of s, default j=-1(string length-</translate>''<br/><!-- GIDEROSMTD:string.sub(s,i,j) returns substring from index i to j of s, default j=-1(string length- -->
+
[[string.sub]] ''returns substring from index i to j of s''<br/><!--GIDEROSMTD:string.sub(s,i,j) returns substring from index i to j of s, default j=string length-->
[[Special:MyLanguage/string.upper|string.upper]] ''<translate>returns string with letters in upper case</translate>''<br/><!-- GIDEROSMTD:string.upper(s) returns string with letters in upper case -->
+
[[string.upper]] ''returns string with letters in upper case''<br/><!--GIDEROSMTD:string.upper(s) returns string with letters in upper case-->
 +
 
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Events</translate> ===
+
=== Events ===
=== <translate>Constants</translate> ===
+
=== Constants ===
 
|}
 
|}
  
 
{{GIDEROS IMPORTANT LINKS}}
 
{{GIDEROS IMPORTANT LINKS}}

Revision as of 07:50, 7 December 2020

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
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
string.upper returns string with letters in upper case

Events

Constants