Garry's Mod Wiki

string.Split

  table string.Split( string Inputstring, string Separator )

Description

Splits the string into a table of strings, separated by the second argument.

This is an alias of string.Explode, but with flipped arguments.

Arguments

1 string Inputstring
String to split
2 string Separator
Character(s) to split with.

Returns

1 table
Split table

Example

Demonstrates the use of this function.

local mystring = "This is some text" PrintTable( string.Split( mystring, " " ) )
Output:
1 = This 2 = is 3 = some 4 = text