diff options
Diffstat (limited to 'doc/classes/String.xml')
-rw-r--r-- | doc/classes/String.xml | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/doc/classes/String.xml b/doc/classes/String.xml index 7592342602..450e483f69 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -126,7 +126,7 @@ [/codeblock] </description> </method> - <method name="contains" qualifiers="const" keywords="includes, has"> + <method name="contains" qualifiers="const"> <return type="bool" /> <param index="0" name="what" type="String" /> <description> @@ -142,7 +142,15 @@ GD.Print("team".Contains("I")); // Prints false [/csharp] [/codeblocks] - If you need to know where [param what] is within the string, use [method find]. + If you need to know where [param what] is within the string, use [method find]. See also [method containsn]. + </description> + </method> + <method name="containsn" qualifiers="const"> + <return type="bool" /> + <param index="0" name="what" type="String" /> + <description> + Returns [code]true[/code] if the string contains [param what], [b]ignoring case[/b]. + If you need to know where [param what] is within the string, use [method findn]. See also [method contains]. </description> </method> <method name="count" qualifiers="const"> @@ -188,7 +196,7 @@ <return type="int" /> <param index="0" name="to" type="String" /> <description> - Like [method naturalcasecmp_to] but prioritises strings that begin with periods ([code].[/code]) and underscores ([code]_[/code]) before any other character. Useful when sorting folders or file names. + Like [method naturalcasecmp_to] but prioritizes strings that begin with periods ([code].[/code]) and underscores ([code]_[/code]) before any other character. Useful when sorting folders or file names. To get a [bool] result from a string comparison, use the [code]==[/code] operator instead. See also [method filenocasecmp_to], [method naturalcasecmp_to], and [method casecmp_to]. </description> </method> @@ -196,7 +204,7 @@ <return type="int" /> <param index="0" name="to" type="String" /> <description> - Like [method naturalnocasecmp_to] but prioritises strings that begin with periods ([code].[/code]) and underscores ([code]_[/code]) before any other character. Useful when sorting folders or file names. + Like [method naturalnocasecmp_to] but prioritizes strings that begin with periods ([code].[/code]) and underscores ([code]_[/code]) before any other character. Useful when sorting folders or file names. To get a [bool] result from a string comparison, use the [code]==[/code] operator instead. See also [method filecasecmp_to], [method naturalnocasecmp_to], and [method nocasecmp_to]. </description> </method> @@ -255,6 +263,13 @@ print("User {id} is {name}.".format([["id", 42], ["name", "Godot"]])) [/codeblock] See also the [url=$DOCS_URL/tutorials/scripting/gdscript/gdscript_format_string.html]GDScript format string[/url] tutorial. + [b]Note:[/b] The replacement of placeholders is not done all at once, instead each placeholder is replaced in the order they are passed, this means that if one of the replacement strings contains a key it will also be replaced. This can be very powerful, but can also cause unexpected results if you are not careful. If you do not need to perform replacement in the replacement strings, make sure your replacements do not contain placeholders to ensure reliable results. + [codeblock] + print("{0} {1}".format(["{1}", "x"])) # Prints "x x". + print("{0} {1}".format(["x", "{0}"])) # Prints "x {0}". + print("{foo} {bar}".format({"foo": "{bar}", "bar": "baz"})) # Prints "baz baz". + print("{foo} {bar}".format({"bar": "baz", "foo": "{bar}"})) # Prints "{bar} baz". + [/codeblock] [b]Note:[/b] In C#, it's recommended to [url=https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated]interpolate strings with "$"[/url], instead. </description> </method> @@ -740,7 +755,7 @@ <method name="reverse" qualifiers="const"> <return type="String" /> <description> - Returns the copy of this string in reverse order. + Returns the copy of this string in reverse order. This operation works on unicode codepoints, rather than sequences of codepoints, and may break things like compound letters or emojis. </description> </method> <method name="rfind" qualifiers="const"> |