Sub
From OxeyeWiki
|
WChar:sub(start[, end]) | ||
|
This method will create a substring of the text object. There are several ways of using the method:
| ||
| Parameter | Expected Type | Description |
| start | An integer | asdf |
| Returns | ||
|
Returns a new WChar object containing the substring. The string will be empty if the parameters are incorrect. | ||
Example
local text = WChar("abc123")
text:sub(1) -- returns "abc123"
text:sub(2) -- returns "bc123"
text:sub(4) -- returns "123"
text:sub(0) -- returns "abc123" (note: may change in future implementations)
text:sub(-1) -- returns "3"
text:sub(-3) -- returns "123"
text:sub(1,1) -- returns "a"
text:sub(1,2) -- returns "ab"
text:sub(1,0) -- returns ""
text:sub(2,3) -- returns "bc"
text:sub(1,-1) -- returns "abc123"
text:sub(1,-2) -- returns "abc12"
text:sub(2,-2) -- returns "bc12"
text:sub(-2,-1) -- returns "23"
text:sub(-2,1) -- returns ""
text:sub(-2,6) -- returns "23"