Added or improved documentation to a few more String methods
(cherry picked from commit f159e7e5ab
)
This commit is contained in:
parent
54eac2aba5
commit
c4041ca8c0
1 changed files with 31 additions and 3 deletions
|
@ -188,7 +188,10 @@
|
|||
<method name="bigrams">
|
||||
<return type="PoolStringArray" />
|
||||
<description>
|
||||
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]
|
||||
</description>
|
||||
</method>
|
||||
<method name="c_escape">
|
||||
|
@ -447,7 +450,14 @@
|
|||
<method name="is_valid_float">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
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]
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_valid_hex_number">
|
||||
|
@ -467,12 +477,24 @@
|
|||
<return type="bool" />
|
||||
<description>
|
||||
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]
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_valid_integer">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
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]
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_valid_ip_address">
|
||||
|
@ -707,7 +729,13 @@
|
|||
<return type="float" />
|
||||
<argument index="0" name="text" type="String" />
|
||||
<description>
|
||||
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]
|
||||
</description>
|
||||
</method>
|
||||
<method name="simplify_path">
|
||||
|
|
Loading…
Reference in a new issue