Browse Source

Fix split/rsplit docs

(cherry picked from commit 79aca6b0c02bfbfd4bf1817baebe1786012c377c)
Zak 5 years ago
parent
commit
7c67b1c9a2
1 changed files with 16 additions and 2 deletions
  1. 16 2
      doc/classes/String.xml

+ 16 - 2
doc/classes/String.xml

@@ -667,7 +667,14 @@
 				Splits the string by a [code]delimiter[/code] string and returns an array of the substrings, starting from right.
 				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.
 				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].
 				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].
-				[b]Example:[/b] [code]"One,Two,Three,Four"[/code] will return [code]["Three","Four"][/code] if split by [code]","[/code] with [code]maxsplit[/code] 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>
 			</description>
 		</method>
 		</method>
 		<method name="rstrip">
 		<method name="rstrip">
@@ -714,7 +721,14 @@
 			<description>
 			<description>
 				Splits the string by a [code]delimiter[/code] string and returns an array of the substrings.
 				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.
 				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.
-				[b]Example:[/b] [code]"One,Two,Three"[/code] will return [code]["One","Two"][/code] if split by [code]","[/code] with [code]maxsplit[/code] 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>
 			</description>
 		</method>
 		</method>
 		<method name="split_floats">
 		<method name="split_floats">