@@ -23,37 +23,20 @@ Splits a string by a separator.
2323#### Parameters
24241 . The string to split.
25252 . The separator to split a string by. This can be any string.
26+ 3 . An optional limit for the returned table size.
2627#### Returns
2728A table.
28- ``` pluto title="Splitting a string by a single character. "
29+ ``` pluto title="Splitting a string by a single character"
2930local s = "hello world, how is everyone doing?"
30- local r = string.split(s, " ")
31- --[[
32- The value of 'r':
33- {
34- "hello",
35- "world,",
36- "how",
37- "is",
38- "everyone",
39- "doing?"
40- }
41- --]]
31+ string.split(s, " ") -- { "hello", "world,", "how", "is", "everyone", "doing?" }
4232```
43- ``` pluto title="Splitting a string by a substring."
44- local s = "helloHALLOWORLDworld,HALLOWORLDhowHALLOWORLDisHALLOWORLDeveryoneHALLOWORLDdoing?"
45- local r = string.split(s, "HALLOWORLD")
46- --[[
47- The value of 'r':
48- {
49- "hello",
50- "world,",
51- "how",
52- "is",
53- "everyone",
54- "doing?"
55- }
56- --]]
33+ ``` pluto title="Splitting a string by a substring"
34+ local s = "helloFOOworld,FOOhowFOOisFOOeveryoneFOOdoing?"
35+ string.split(s, "FOO") -- { "hello", "world,", "how", "is", "everyone", "doing?" }
36+ ```
37+ ``` pluto title="Splitting a string by a single character with a limit"
38+ local s = "hello world, how is everyone doing?"
39+ string.split(s, " ", 3) -- { "hello", "world,", "how is everyone doing?" }
5740```
5841---
5942### ` string.rfind `
0 commit comments