String

From GMod Wiki

Jump to: navigation, search

A string is simply a line of text. Text can have both numbers and text in it, but you shouldn't use strings for math or for any functions that need numbers specifically.

Be aware - strings are often very large, and by consequence much slower than other types of data. Avoid networking strings or performing operations on strings every frame whenever possible.

Library Functions

NewerShared.png string.byte
NewerShared.png string.char
NewerShared.png string.dump
NewerShared.png string.Explode
NewerShared.png string.find
NewerShared.png string.format
NewerShared.png string.FormattedTime
NewerShared.png string.GetExtensionFromFilename
NewerShared.png string.GetFileFromFilename
NewerShared.png string.GetPathFromFilename
NewerShared.png string.gfind
NewerShared.png string.gmatch
NewerShared.png string.gsub
NewerShared.png string.Implode
NewerShared.png string.Left
NewerShared.png string.len
NewerShared.png string.lower
NewerShared.png string.NiceSize
NewerShared.png string.match
NewerShared.png string.rep
NewerShared.png string.Replace
NewerShared.png string.reverse
NewerShared.png string.Right
NewerShared.png string.split
NewerShared.png string.sub
NewerShared.png string.ToMinutesSeconds
NewerShared.png string.ToMinutesSecondsMilliseconds
NewerShared.png string.ToTable
NewerShared.png string.Trim
NewerShared.png string.TrimLeft
NewerShared.png string.TrimRight
NewerShared.png string.upper

Example

DescriptionWays to Declare a string
Used onNewerShared.png
Code
 
my_string = "a string"

This version is most commonly used. You can indicate a break with \n (stands for newline) and put in " with \". You cant use a direct break with this type of string.

my_string_two = [[a string,
 this time multiline!]]

This version is often used for info showing up in console, because you can just write down your text how you want it to look in console. No need for \ stuff.

my_string_three = 'a string'
OutputN/A


If you want to split a string use string.Explode

Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox