updated the String class with info about the 'allow_empty' optional argument

(cherry picked from commit 39233c299c)
This commit is contained in:
Tom 2022-08-05 22:16:43 +01:00 committed by Rémi Verschelde
parent 60031ea275
commit 295b531e3d

View file

@ -696,6 +696,7 @@
<description> <description>
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]allow_empty[/code] is [code]true[/code], and there are two adjacent delimiters in the string, it will add an empty string to the array of substrings at this position.
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].
Example: Example:
[codeblock] [codeblock]
@ -765,6 +766,7 @@
<argument index="2" name="maxsplit" type="int" default="0" /> <argument index="2" name="maxsplit" type="int" default="0" />
<description> <description>
Splits the string by a [code]delimiter[/code] string and returns an array of the substrings. The [code]delimiter[/code] can be of any length. Splits the string by a [code]delimiter[/code] string and returns an array of the substrings. The [code]delimiter[/code] can be of any length.
If [code]allow_empty[/code] is [code]true[/code], and there are two adjacent delimiters in the string, it will add an empty string to the array of substrings at this position.
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 [code]0[/code] 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 [code]0[/code] means that all items are split.
If you need only one element from the array at a specific index, [method get_slice] is a more performant option. If you need only one element from the array at a specific index, [method get_slice] is a more performant option.
Example: Example:
@ -785,6 +787,7 @@
<description> <description>
Splits the string in floats by using a delimiter string and returns an array of the substrings. Splits the string in floats by using a delimiter string and returns an array of the substrings.
For example, [code]"1,2.5,3"[/code] will return [code][1,2.5,3][/code] if split by [code]","[/code]. For example, [code]"1,2.5,3"[/code] will return [code][1,2.5,3][/code] if split by [code]","[/code].
If [code]allow_empty[/code] is [code]true[/code], and there are two adjacent delimiters in the string, it will add an empty string to the array of substrings at this position.
</description> </description>
</method> </method>
<method name="strip_edges"> <method name="strip_edges">