string.sub
Returns a substring of a string
Prototype
s = string.sub (str, start, end)
Description
Returns a substring of the string, starting at index 'start' and ending at index 'end'. Both may be negative to indicate counting from the right. The end point is optional and defaults to -1, which is the entire rest of the string.
string.sub ("ABCDEF", 2, 3) --> BC
string.sub ("ABCDEF", 3) --> CDEF
string.sub ("ABCDEF", -1) --> F
See also utils.utf8sub for doing the identical operation with UTF-8 strings.Lua functions
- string.byte - Converts a character into its ASCII (decimal) equivalent
- string.char - Converts ASCII codes into their equivalent characters
- string.dump - Converts a function into binary
- string.find - Searches a string for a pattern
- string.format - Formats a string
- string.gfind - Iterate over a string (obsolete in Lua 5.1)
- string.gmatch - Iterate over a string
- string.gsub - Substitute strings inside another string
- string.len - Return the length of a string
- string.lower - Converts a string to lower-case
- string.match - Searches a string for a pattern
- string.rep - Returns repeated copies of a string
- string.reverse - Reverses the order of characters in a string
- string.upper - Converts a string to upper-case
Topics
- Lua LPEG library
- Lua PCRE regular expression functions
- Lua base functions
- Lua bc (big number) functions
- Lua bit manipulation functions
- Lua coroutine functions
- Lua debug functions
- Lua io functions
- Lua math functions
- Lua os functions
- Lua package functions
- Lua script extensions
- Lua string functions
- Lua syntax
- Lua table functions
- Lua utilities
- Regular Expressions
- Scripting callbacks - plugins
- Scripting