|
5 | 5 | </brief_description> |
6 | 6 | <description> |
7 | 7 | This is the built-in string Variant type (and the one used by GDScript). Strings may contain any number of Unicode characters, and expose methods useful for manipulating and generating strings. Strings are reference-counted and use a copy-on-write approach (every modification to a string returns a new [String]), so passing them around is cheap in resources. |
8 | | - Some string methods have corresponding variations. Variations suffixed with [code]n[/code] ([method countn], [method findn], [method replacen], etc.) are [b]case-insensitive[/b] (they make no distinction between uppercase and lowercase letters). Method variations prefixed with [code]r[/code] ([method rfind], [method rsplit], etc.) are reversed, and start from the end of the string, instead of the beginning. |
| 8 | + Some string methods have corresponding variations. For example, string-comparison methods are [b]case-sensitive[/b] by default but have [b]case-insensitive[/b] variations suffixed with [code]n[/code] ([method countn], [method findn], [method replacen], etc.) which treat uppercase and lowercase letters as equal. Another example is method variations prefixed with [code]r[/code] ([method rfind], [method rsplit], etc.) where processing is reversed, starting from the end of the string instead of the beginning. |
9 | 9 | To convert any [Variant] to or from a string, see [method @GlobalScope.str], [method @GlobalScope.str_to_var], and [method @GlobalScope.var_to_str]. |
10 | 10 | [b]Note:[/b] In a boolean context, a string will evaluate to [code]false[/code] if it is empty ([code]""[/code]). Otherwise, a string will always evaluate to [code]true[/code]. |
11 | 11 | </description> |
|
132 | 132 | <return type="bool" /> |
133 | 133 | <param index="0" name="what" type="String" /> |
134 | 134 | <description> |
135 | | - Returns [code]true[/code] if the string contains [param what]. In GDScript, this corresponds to the [code]in[/code] operator. |
| 135 | + Returns [code]true[/code] if the string contains [param what] (case-sensitive). In GDScript, this corresponds to the [code]in[/code] operator. See [method containsn] for a case-insensitive version. |
136 | 136 | [codeblocks] |
137 | 137 | [gdscript] |
138 | 138 | print("Node".contains("de")) # Prints true |
|
144 | 144 | GD.Print("team".Contains("I")); // Prints False |
145 | 145 | [/csharp] |
146 | 146 | [/codeblocks] |
147 | | - If you need to know where [param what] is within the string, use [method find]. See also [method containsn]. |
| 147 | + If you need to know where [param what] is within the string, use [method find]. |
148 | 148 | </description> |
149 | 149 | </method> |
150 | 150 | <method name="containsn" qualifiers="const"> |
151 | 151 | <return type="bool" /> |
152 | 152 | <param index="0" name="what" type="String" /> |
153 | 153 | <description> |
154 | | - Returns [code]true[/code] if the string contains [param what], [b]ignoring case[/b]. |
155 | | - If you need to know where [param what] is within the string, use [method findn]. See also [method contains]. |
| 154 | + Returns [code]true[/code] if the string contains [param what], [b]ignoring case[/b]. See [method contains] for a case-sensitive version. |
| 155 | + If you need to know where [param what] is within the string, use [method findn]. |
156 | 156 | </description> |
157 | 157 | </method> |
158 | 158 | <method name="count" qualifiers="const"> |
|
161 | 161 | <param index="1" name="from" type="int" default="0" /> |
162 | 162 | <param index="2" name="to" type="int" default="0" /> |
163 | 163 | <description> |
164 | | - Returns the number of occurrences of the substring [param what] between [param from] and [param to] positions. If [param to] is 0, the search continues until the end of the string. |
| 164 | + Returns the number of case-sensitive occurrences of the substring [param what] between [param from] and [param to] positions. If [param to] is 0, the search continues until the end of the string. See [method countn] for a case-insensitive version. |
165 | 165 | </description> |
166 | 166 | </method> |
167 | 167 | <method name="countn" qualifiers="const"> |
|
170 | 170 | <param index="1" name="from" type="int" default="0" /> |
171 | 171 | <param index="2" name="to" type="int" default="0" /> |
172 | 172 | <description> |
173 | | - Returns the number of occurrences of the substring [param what] between [param from] and [param to] positions, [b]ignoring case[/b]. If [param to] is 0, the search continues until the end of the string. |
| 173 | + Returns the number of occurrences of the substring [param what] between [param from] and [param to] positions, [b]ignoring case[/b]. If [param to] is 0, the search continues until the end of the string. See [method count] for a case-sensitive version. |
174 | 174 | </description> |
175 | 175 | </method> |
176 | 176 | <method name="dedent" qualifiers="const"> |
|
183 | 183 | <return type="bool" /> |
184 | 184 | <param index="0" name="text" type="String" /> |
185 | 185 | <description> |
186 | | - Returns [code]true[/code] if the string ends with the given [param text]. See also [method begins_with]. |
| 186 | + Returns [code]true[/code] if the string ends with the given [param text] (case-sensitive). See also [method begins_with]. |
187 | 187 | </description> |
188 | 188 | </method> |
189 | 189 | <method name="erase" qualifiers="const"> |
|
215 | 215 | <param index="0" name="what" type="String" /> |
216 | 216 | <param index="1" name="from" type="int" default="0" /> |
217 | 217 | <description> |
218 | | - Returns the index of the [b]first[/b] occurrence of [param what] in this string, or [code]-1[/code] if there are none. The search's start can be specified with [param from], continuing to the end of the string. |
| 218 | + Returns the index of the [b]first[/b] case-sensitive occurrence of [param what] in this string, or [code]-1[/code] if there are none. The search's start can be specified with [param from], continuing to the end of the string. See [method findn] for a case-insensitive version. |
219 | 219 | [codeblocks] |
220 | 220 | [gdscript] |
221 | 221 | print("Team".find("I")) # Prints -1 |
|
240 | 240 | <param index="0" name="what" type="String" /> |
241 | 241 | <param index="1" name="from" type="int" default="0" /> |
242 | 242 | <description> |
243 | | - Returns the index of the [b]first[/b] [b]case-insensitive[/b] occurrence of [param what] in this string, or [code]-1[/code] if there are none. The starting search index can be specified with [param from], continuing to the end of the string. |
| 243 | + Returns the index of the [b]first[/b] [b]case-insensitive[/b] occurrence of [param what] in this string, or [code]-1[/code] if there are none. The starting search index can be specified with [param from], continuing to the end of the string. See [method find] for a case-sensitive version. |
244 | 244 | </description> |
245 | 245 | </method> |
246 | 246 | <method name="format" qualifiers="const"> |
|
441 | 441 | <return type="bool" /> |
442 | 442 | <param index="0" name="text" type="String" /> |
443 | 443 | <description> |
444 | | - Returns [code]true[/code] if all characters of this string can be found in [param text] in their original order. This is not the same as [method contains]. |
| 444 | + Returns [code]true[/code] if all characters of this string can be found in [param text] (case-sensitive) in their original order. This is not the same as [method contains]. See [method is_subsequence_ofn] for a case-insensitive version. |
445 | 445 | [codeblock] |
446 | 446 | var text = "Wow, incredible!" |
447 | 447 |
|
|
456 | 456 | <return type="bool" /> |
457 | 457 | <param index="0" name="text" type="String" /> |
458 | 458 | <description> |
459 | | - Returns [code]true[/code] if all characters of this string can be found in [param text] in their original order, [b]ignoring case[/b]. This is not the same as [method containsn]. |
| 459 | + Returns [code]true[/code] if all characters of this string can be found in [param text] in their original order, [b]ignoring case[/b]. This is not the same as [method containsn]. See [method is_subsequence_of] for a case-sensitive version. |
460 | 460 | </description> |
461 | 461 | </method> |
462 | 462 | <method name="is_valid_ascii_identifier" qualifiers="const"> |
|
624 | 624 | <return type="bool" /> |
625 | 625 | <param index="0" name="expr" type="String" /> |
626 | 626 | <description> |
627 | | - Does a simple expression match (also called "glob" or "globbing"), where [code]*[/code] matches zero or more arbitrary characters and [code]?[/code] matches any single character except a period ([code].[/code]). An empty string or empty expression always evaluates to [code]false[/code]. |
| 627 | + Does a simple expression match (also called "glob" or "globbing"), where [code]*[/code] matches zero or more arbitrary characters and [code]?[/code] matches any single character except a period ([code].[/code]). String matching is case-sensitive. See [method matchn] for a case-insensitive version. An empty string or empty expression always evaluates to [code]false[/code]. |
628 | 628 | </description> |
629 | 629 | </method> |
630 | 630 | <method name="matchn" qualifiers="const"> |
631 | 631 | <return type="bool" /> |
632 | 632 | <param index="0" name="expr" type="String" /> |
633 | 633 | <description> |
634 | | - Does a simple [b]case-insensitive[/b] expression match, where [code]*[/code] matches zero or more arbitrary characters and [code]?[/code] matches any single character except a period ([code].[/code]). An empty string or empty expression always evaluates to [code]false[/code]. |
| 634 | + Does a simple [b]case-insensitive[/b] expression match, where [code]*[/code] matches zero or more arbitrary characters and [code]?[/code] matches any single character except a period ([code].[/code]). See [method match] for a case-sensitive version. An empty string or empty expression always evaluates to [code]false[/code]. |
635 | 635 | </description> |
636 | 636 | </method> |
637 | 637 | <method name="md5_buffer" qualifiers="const"> |
|
790 | 790 | <param index="0" name="what" type="String" /> |
791 | 791 | <param index="1" name="forwhat" type="String" /> |
792 | 792 | <description> |
793 | | - Replaces all occurrences of [param what] inside the string with the given [param forwhat]. |
| 793 | + Replaces all case-sensitive occurrences of [param what] inside the string with the given [param forwhat]. See [method replacen] for a case-insensitive version. |
794 | 794 | </description> |
795 | 795 | </method> |
796 | 796 | <method name="replace_char" qualifiers="const"> |
|
814 | 814 | <param index="0" name="what" type="String" /> |
815 | 815 | <param index="1" name="forwhat" type="String" /> |
816 | 816 | <description> |
817 | | - Replaces all [b]case-insensitive[/b] occurrences of [param what] inside the string with the given [param forwhat]. |
| 817 | + Replaces all [b]case-insensitive[/b] occurrences of [param what] inside the string with the given [param forwhat]. See [method replace] for a case-sensitive version. |
818 | 818 | </description> |
819 | 819 | </method> |
820 | 820 | <method name="reverse" qualifiers="const"> |
|
828 | 828 | <param index="0" name="what" type="String" /> |
829 | 829 | <param index="1" name="from" type="int" default="-1" /> |
830 | 830 | <description> |
831 | | - Returns the index of the [b]last[/b] occurrence of [param what] in this string, or [code]-1[/code] if there are none. The search's start can be specified with [param from], continuing to the beginning of the string. This method is the reverse of [method find]. |
| 831 | + Returns the index of the [b]last[/b] case-sensitive occurrence of [param what] in this string, or [code]-1[/code] if there are none. The search's start can be specified with [param from], continuing to the beginning of the string. This method is the reverse of [method find]. See [method rfindn] for a case-insensitive version. |
832 | 832 | </description> |
833 | 833 | </method> |
834 | 834 | <method name="rfindn" qualifiers="const"> |
835 | 835 | <return type="int" /> |
836 | 836 | <param index="0" name="what" type="String" /> |
837 | 837 | <param index="1" name="from" type="int" default="-1" /> |
838 | 838 | <description> |
839 | | - Returns the index of the [b]last[/b] [b]case-insensitive[/b] occurrence of [param what] in this string, or [code]-1[/code] if there are none. The starting search index can be specified with [param from], continuing to the beginning of the string. This method is the reverse of [method findn]. |
| 839 | + Returns the index of the [b]last[/b] [b]case-insensitive[/b] occurrence of [param what] in this string, or [code]-1[/code] if there are none. The starting search index can be specified with [param from], continuing to the beginning of the string. This method is the reverse of [method findn]. See [method rfind] for a case-sensitive version. |
840 | 840 | </description> |
841 | 841 | </method> |
842 | 842 | <method name="right" qualifiers="const"> |
|
0 commit comments