diff options
author | Zak <zakscomputers@hotmail.com> | 2019-11-13 14:16:07 +0200 |
---|---|---|
committer | Zak <zakscomputers@hotmail.com> | 2019-11-13 14:58:19 +0200 |
commit | 79aca6b0c02bfbfd4bf1817baebe1786012c377c (patch) | |
tree | a98e8898217a3b27c47bc9dad3f3e0ef382dacef /doc/classes | |
parent | c1b0800784fd2538d0a0f32cbc2310de667d47f7 (diff) |
Fix split/rsplit docs
Diffstat (limited to 'doc/classes')
-rw-r--r-- | doc/classes/String.xml | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/doc/classes/String.xml b/doc/classes/String.xml index cf152e716e..591dda9014 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -744,7 +744,15 @@ Splits the string by a [code]delimiter[/code] string and returns an array of the substrings, starting from right. The splits in the returned array are sorted in the same order as the original string, from left to right. If [code]maxsplit[/code] is specified, it defines the number of splits to do from the right up to [code]maxsplit[/code]. The default value of 0 means that all items are split, thus giving the same result as [method split]. - For example, [code]"One,Two,Three,Four"[/code] will return [code]["Three","Four"][/code] if split by [code]","[/code] with a [code]maxsplit[/code] value of 2. + Example: + [codeblock] + var some_string = "One,Two,Three,Four" + var some_array = some_string.rsplit(",", true, 1) + print(some_array.size()) # Prints 2 + print(some_array[0]) # Prints "Four" + print(some_array[1]) # Prints "Three,Two,One" + [/codeblock] + </description> </method> <method name="rstrip"> @@ -805,7 +813,14 @@ <description> Splits the string by a [code]delimiter[/code] string and returns an array of the substrings. If [code]maxsplit[/code] is specified, it defines the number of splits to do from the left up to [code]maxsplit[/code]. The default value of 0 means that all items are split. - For example, [code]"One,Two,Three"[/code] will return [code]["One","Two"][/code] if split by [code]","[/code] with a [code]maxsplit[/code] value of 2. + Example: + [codeblock] + var some_string = "One,Two,Three,Four" + var some_array = some_string.split(",", true, 1) + print(some_array.size()) # Prints 2 + print(some_array[0]) # Prints "One" + print(some_array[1]) # Prints "Two,Three,Four" + [/codeblock] </description> </method> <method name="split_floats"> |