From f159e7e5ab2a833412d458343a6eb2896a8abb56 Mon Sep 17 00:00:00 2001
From: Nova <3247833+novaplusplus@users.noreply.github.com>
Date: Tue, 22 Feb 2022 15:13:34 -0500
Subject: [PATCH] Added or improved documentation to a few more String methods
---
doc/classes/String.xml | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index 5f133169f2b..d85e521f086 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -49,7 +49,10 @@
- Returns the bigrams (pairs of consecutive letters) of this string.
+ Returns an array containing the bigrams (pairs of consecutive letters) of this string.
+ [codeblock]
+ print("Bigrams".bigrams()) # Prints "[Bi, ig, gr, ra, am, ms]"
+ [/codeblock]
@@ -101,6 +104,11 @@
+ Directly converts an decimal integer to a unicode character. Tables of these characters can be found in various locations, for example [url=https://unicodelookup.com/]here.[/url]
+ [codeblock]
+ print(String.chr(65)) # Prints "A"
+ print(String.chr(129302)) # Prints "🤖" (robot face emoji)
+ [/codeblock]
@@ -328,7 +336,14 @@
- Returns [code]true[/code] if this string contains a valid float.
+ Returns [code]true[/code] if this string contains a valid float. This is inclusive of integers, and also supports exponents:
+ [codeblock]
+ print("1.7".is_valid_float()) # Prints "true"
+ print("24".is_valid_float()) # Prints "true"
+ print("7e3".is_valid_float()) # Prints "true"
+ print("24".is_valid_float()) # Prints "true"
+ print("Hello".is_valid_float()) # Prints "false"
+ [/codeblock]
@@ -348,12 +363,24 @@
Returns [code]true[/code] if this string is a valid identifier. A valid identifier may contain only letters, digits and underscores ([code]_[/code]) and the first character may not be a digit.
+ [codeblock]
+ print("good_ident_1".is_valid_identifier()) # Prints "true"
+ print("1st_bad_ident".is_valid_identifier()) # Prints "false"
+ print("bad_ident_#2".is_valid_identifier()) # Prints "false"
+ [/codeblock]
Returns [code]true[/code] if this string contains a valid integer.
+ [codeblock]
+ print("7".is_valid_int()) # Prints "true"
+ print("14.6".is_valid_int()) # Prints "false"
+ print("L".is_valid_int()) # Prints "false"
+ print("+3".is_valid_int()) # Prints "true"
+ print("-12".is_valid_int()) # Prints "true"
+ [/codeblock]
@@ -633,7 +660,13 @@
- Returns the similarity index of the text compared to this string. 1 means totally similar and 0 means totally dissimilar.
+ Returns the similarity index ([url=https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient]Sorensen-Dice coefficient[/url]) this string compared to another. 1.0 means totally similar and 0.0 means totally dissimilar.
+ [codeblock]
+ print("ABC123".similarity("ABC123")) # Prints "1"
+ print("ABC123".similarity("XYZ456")) # Prints "0"
+ print("ABC123".similarity("123ABC")) # Prints "0.8"
+ print("ABC123".similarity("abc123")) # Prints "0.4"
+ [/codeblock]