summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-08-20 09:24:01 +0200
committerGitHub <noreply@github.com>2021-08-20 09:24:01 +0200
commit0168699d7a0449ae0b17ce866725c6a80f99b87a (patch)
tree6906692f28451312157d8a6cace67c1644d52c7c /doc
parenta264f75846c3179914fcd97a5a9c55e051d69f0c (diff)
parent09eb98c5306f8d9a17287aa5a7509e17d56f2ee0 (diff)
Merge pull request #51905 from Calinou/doc-string-get-extension
Improve documentation for `String.get_extension()`
Diffstat (limited to 'doc')
-rw-r--r--doc/classes/String.xml12
1 files changed, 11 insertions, 1 deletions
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index 467e2f901f..97efc24bd1 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -181,7 +181,17 @@
<method name="get_extension" qualifiers="const">
<return type="String" />
<description>
- If the string is a valid file path, returns the extension.
+ Returns the extension without the leading period character ([code].[/code]) if the string is a valid file name or path. If the string does not contain an extension, returns an empty string instead.
+ [codeblock]
+ print("/path/to/file.txt".get_extension()) # "txt"
+ print("file.txt".get_extension()) # "txt"
+ print("file.sample.txt".get_extension()) # "txt"
+ print(".txt".get_extension()) # "txt"
+ print("file.txt.".get_extension()) # "" (empty string)
+ print("file.txt..".get_extension()) # "" (empty string)
+ print("txt".get_extension()) # "" (empty string)
+ print("".get_extension()) # "" (empty string)
+ [/codeblock]
</description>
</method>
<method name="get_file" qualifiers="const">