Garry's Mod Wiki

string.sub

string string.sub( string string, number StartPos, number EndPos = nil )

Description

Returns a sub-string, starting from the character at position StartPos of the string (inclusive), and optionally ending at the character at position EndPos of the string (also inclusive). If EndPos is not given, the rest of the string is returned.

Arguments

1 string string
The string you'll take a sub-string out of.
2 number StartPos
The position of the first character that will be included in the sub-string.
3 number EndPos = nil
The position of the last character to be included in the sub-string. It can be negative to count from the end.

Returns

1 string
The substring.

Example

Demonstrates the use of this function.

local mystring = "Some random text" print(string.sub(mystring, 1, 4))
Output: Some

Page Links


Special Pages


Wikis

?

Render Time: 39ms

Session 0
DB GetPage 4
Generate Html 13
SaveChanges 9
Render Body 0
Render Sidebar 11