Try Install Learn Blog API Packages GitHub
Pages
Standard Library

Search
Entities

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"
dropLeft
(
number
:
Number
string
:
String
)
:
String

Drops the number of characters from the string.

String.dropLeft(1, "abc") == "bc"
String.dropLeft(2, "abc") == "c"
fromArray
(
array
:
Array(String)
)
:
String

Joins the given array of strings, alias for String.concat.

String.fromArray(["A","B","C"]) == "ABC"
indent
(
by
:
Number
string
:
String
)
:
String

Indents the string with the given number of spaces.

String.indent(2, "Hello There!") == "  Hello There!"
indentWithOptions
(
by
:
Number
character
:
String
includeEmptyLines
:
Bool
string
:
String
)
:
String

Indents the string with the given number of characters using the given options.

String.indentWithOptions(2, "-", false, "Hello There!") == "--Hello There!"
isAnagram
(
string1
:
String
string2
:
String
)
:
Bool

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

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

Returns whether or not the string is blank (only contains whitespace).

 String.isBlank("") == true
 String.isBlank(" ") == true
 String.isBlank("a") == false
isEmpty
(
string
:
String
)
:
Bool

Returns whether or not the string is empty ("").

 String.isEmpty("") == true
 String.isEmpty("a") == false
 String.isEmpty(" ") == false
isNotBlank
(
string
:
String
)
:
Bool

Returns whether or not the string is not blank.

String.isNotBlank("a") == true
String.isNotBlank("   ") == false
isNotEmpty
(
string
:
String
)
:
Bool

Returns whether or not the string is not empty.

String.isNotEmpty("a") == true
String.isNotEmpty("   ") == true
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 occurrences 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
parameterize
(
string
:
String
)
:
String

Parameterizes the string:

  • replaces non alphanumeric, dash and underscore characters with dash

  • converts title case to dash case (TitleCase -> title-case)

  • collapses multiple dashes into a single one

  • removes the leading and trailing dash(es)

  • converts to lowercase

    String.parameterize("Ui.ActionSheet") == "ui-action-sheet" String.parameterize("HELLO THERE!!!") == "hello-there" String.parameterize("-!ASD!-") == "asd"

rchop
(
char
:
String
string
:
String
)
:
String

Removes all occurrences 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 replacements.

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"]
toArray
(
string
:
String
)
:
Array(String)

Convert the given string into an array of strings.

String.toArray("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"
wrap
(
start
:
String
end
:
String
string
:
String
)
:
String

Wraps the string with the given start and end characters.

String.wrap("{","}", "Hello there!") == "{Hello there!}"