diff options
Diffstat (limited to 'doc/classes/String.xml')
-rw-r--r-- | doc/classes/String.xml | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/doc/classes/String.xml b/doc/classes/String.xml index 97466e7860..8535dacda7 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -193,8 +193,8 @@ GD.Print("Team".Find("I")); // Prints -1 GD.Print("Potato".Find("t")); // Prints 2 - GD.print("Potato".Find("t", 3)); // Prints 4 - GD.print("Potato".Find("t", 5)); // Prints -1 + GD.Print("Potato".Find("t", 3)); // Prints 4 + GD.Print("Potato".Find("t", 5)); // Prints -1 [/csharp] [/codeblocks] [b]Note:[/b] If you just want to know whether the string contains [param what], use [method contains]. In GDScript, you may also use the [code]in[/code] operator. @@ -230,6 +230,7 @@ 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] 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> <method name="get_base_dir" qualifiers="const"> @@ -480,7 +481,7 @@ var fruits = new string[] {"Apple", "Orange", "Pear", "Kiwi"}; // In C#, this method is static. - GD.Print(string.Join(", ", fruits); // Prints "Apple, Orange, Pear, Kiwi" + GD.Print(string.Join(", ", fruits)); // Prints "Apple, Orange, Pear, Kiwi" GD.Print(string.Join("---", fruits)); // Prints "Apple---Orange---Pear---Kiwi" [/csharp] [/codeblocks] @@ -529,7 +530,7 @@ <return type="bool" /> <param index="0" name="expr" type="String" /> <description> - Does a simple 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]. + 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]. </description> </method> <method name="matchn" qualifiers="const"> @@ -1002,10 +1003,16 @@ [/codeblocks] </description> </method> + <method name="validate_filename" qualifiers="const"> + <return type="String" /> + <description> + Returns a copy of the string with all characters that are not allowed in [method is_valid_filename] replaced with underscores. + </description> + </method> <method name="validate_node_name" qualifiers="const"> <return type="String" /> <description> - Removes all characters that are not allowed in [member Node.name] from the string ([code].[/code] [code]:[/code] [code]@[/code] [code]/[/code] [code]"[/code] [code]%[/code]). + Returns a copy of the string with all characters that are not allowed in [member Node.name] removed ([code].[/code] [code]:[/code] [code]@[/code] [code]/[/code] [code]"[/code] [code]%[/code]). </description> </method> <method name="xml_escape" qualifiers="const"> @@ -1041,8 +1048,7 @@ <return type="String" /> <param index="0" name="right" type="Variant" /> <description> - Formats the [String], replacing the placeholders with one or more parameters. - To pass multiple parameters, [param right] needs to be an [Array]. + Formats the [String], replacing the placeholders with one or more parameters. To pass multiple parameters, [param right] needs to be an [Array]. [codeblock] print("I caught %d fishes!" % 2) # Prints "I caught 2 fishes!" @@ -1051,8 +1057,8 @@ var speed = 40.3485 print(my_message % [location, speed]) # Prints "Travelling to Deep Valley, at 40.35 km/h." [/codeblock] - In C#, there is no direct equivalent to this operator. Use the [method format] method, instead. For more information, see the [url=$DOCS_URL/tutorials/scripting/gdscript/gdscript_format_string.html]GDScript format strings[/url] tutorial. + [b]Note:[/b] In C#, this operator is not available. Instead, see [url=https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated]how to interpolate strings with "$"[/url]. </description> </operator> <operator name="operator +"> @@ -1066,6 +1072,7 @@ <return type="String" /> <param index="0" name="right" type="StringName" /> <description> + Appends [param right] at the end of this [String], returning a [String]. This is also known as a string concatenation. </description> </operator> <operator name="operator <"> |