Difference between revisions of "String.sub"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2011.6<br/> === Description === Returns the substring of s that starts at i and continues until j; i and j can be negative. If j is ab...")
 
Line 4: Line 4:
 
Returns the substring of s that starts at i and continues until j; i and j can be negative. If j is absent, then it is assumed to be equal to -1 (which is the same as the string length). In particular, the call string.sub(s,1,j) returns a prefix of s with length j, and string.sub(s, -i) returns a suffix of s with length i.
 
Returns the substring of s that starts at i and continues until j; i and j can be negative. If j is absent, then it is assumed to be equal to -1 (which is the same as the string length). In particular, the call string.sub(s,1,j) returns a prefix of s with length j, and string.sub(s, -i) returns a suffix of s with length i.
 
<source lang="lua">
 
<source lang="lua">
(string), = string.sub(sij,)
+
(string) = string.sub(s,i,j)
 
</source>
 
</source>
'''s:''' (string) string to get substring from ''''''<br/>
+
'''s''': (string) string to get substring from ''''''<br/>
'''i:''' (number) start index of substring ''''''<br/>
+
'''i''': (number) start index of substring ''''''<br/>
'''j:''' (number) index of the last character of substring '''optional'''<br/>
+
'''j''': (number) index of the last character of substring '''optional'''<br/>
 
'''Returns''' (string) substring<br/>
 
'''Returns''' (string) substring<br/>

Revision as of 10:20, 23 August 2018

Available since: Gideros 2011.6

Description

Returns the substring of s that starts at i and continues until j; i and j can be negative. If j is absent, then it is assumed to be equal to -1 (which is the same as the string length). In particular, the call string.sub(s,1,j) returns a prefix of s with length j, and string.sub(s, -i) returns a suffix of s with length i.

(string) = string.sub(s,i,j)

's: (string) string to get substring from '
'i: (number) start index of substring '
j: (number) index of the last character of substring optional
Returns (string) substring