Try Install Learn Blog API Packages GitHub
Pages

String

Utility functions for working with String.

Functions

capitalize
(
string
:
String
)
:
String

Capitalizes each letter in the given string.

String.capitalize("the cake is a lie!") == "The Cake Is A Lie!"
concat
(
array
:
Array(String)
)
:
String

Joins the given array of strings.

String.concat(["A","B","C"]) == "ABC"
isAnagarm
(
string1
:
String
string2
:
String
)
:
Bool

Returns if the given string is an anagram of the other string.

String.isAnagarm("asd", "blah") == false
String.isAnagarm("rail safety", "fairy tales") == true
isEmpty
(
string
:
String
)
:
Bool

Returns whether or not the string is empty.

 String.isEmpty("") == true
 String.isEmpty("a") == false
 String.isEmpty(" ") == false
join
(
separator
:
String
array
:
Array(String)
)
:
String

Joins the given array of string into a single string using the separator.

String.join(",", ["A","B","C"]) == "A,B,C"
lchop
(
char
:
String
string
:
String
)
:
String

Removes all occurances of the given character from the start of the given string.

String.lchop("!", "!!!Hello") == "Hello"
match
(
pattern
:
String
string
:
String
)
:
Bool

Returns if the given pattern is included in the given string.

 String.match("A", "ABC") == true
 String.match("X", "ABC") == false
rchop
(
char
:
String
string
:
String
)
:
String

Removes all occurances of the given character from the end of the given string.

String.rchop("!", "Hello!!!") == "Hello"
repeat
(
times
:
Number
string
:
String
)
:
String

Repeats the given string the given number of times.

String.repeat(5, "A") == "AAAAA"
replace
(
pattern
:
String
replacement
:
String
string
:
String
)
:
String

Replaces the given pattern with the replacemet.

String.replace("a", "0", "aaaa") == "0000"
reverse
(
string
:
String
)
:
String

Reverses the given string.

 String.reverse("ABC") == "CBA"
size
(
string
:
String
)
:
Number

Returns number of characters in the given string.

String.size("ABC") == 3
split
(
separator
:
String
string
:
String
)
:
Array(String)

Splits the given string using the given separator.

String.split("", "AAA") = ["A", "A", "A"]
toLowerCase
(
string
:
String
)
:
String

Converts the given string to lowercase.

 String.toLowerCase("ABC") == "abc"
toUpperCase
(
string
:
String
)
:
String

Converts the given string to lowercase.

 String.toUpperCase("abc") == "ABC"
trim
(
value
:
String
)
:
String

Removes whitespace from the beginning and end of the string.

String.trim("  asd ") == "asd"
withDefault
(
value
:
String
string
:
String
)
:
String

Returns the given string or the given default value if the string is empty.

String.withDefault("default", "") == "default"
String.withDefault("default", "something") == "something"