string/Split

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=Split |Parent=string |Description=Splits the string into a table of strings, separated by the second argument. |Realm=Shared |IsClass=No }} {{Arg |type=str...")
 
m
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=Split
 
|Parent=string
 
 
|Description=Splits the string into a table of strings, separated by the second argument.
 
|Description=Splits the string into a table of strings, separated by the second argument.
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=No
 
|IsClass=No
 +
|Name=Split
 +
|Parent=string
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 18: Line 18:
 
{{Ret
 
{{Ret
 
|type=table
 
|type=table
|desc= Splitted table
+
|desc=Splitted table
 +
}}
 +
{{Example
 +
|Description=Demonstrates the use of this function.
 +
|Code=local mystring = "This is some text"
 +
local mytable = string.Split( mystring, " " )
 +
print( string.Implode( ", ", mytable )
 +
|Output=This, is, some, text
 
}}
 
}}

Revision as of 14:58, 3 October 2015

 string.Split( )

Contents

Description

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

Arguments

string Inputstring

String to split

Arguments

string Separator

Character(s) to split with.

Returns

table

Splitted table

Examples

Example

Demonstrates the use of this function.

local mystring = "This is some text"
local mytable = string.Split( mystring, " " )
print( string.Implode( ", ", mytable )

Output:

This, is, some, text
Personal tools
Navigation