String¶
Represents a string value. Strings can be prefixed with r to parse them as they are. Strings are always multi-line.
'[\S\s]*'
"[\S\s]*"
r'[\S\s]*'
r"[\S\s]*"
'Hello'
"Hello"
r'This is a raw string'
r"This is a raw string"
'Supports escape sequences like \t \n'
"but also unicodes like \u0041 and \x41"
'Easy
and
peasy'
Properties¶
isEmpty¶
Is string empty?
() => Boolean
isNotEmpty¶
Is string not empty?
() => Boolean
length¶
Length of the string.
() => Number
compareTo¶
Compare to another string. Returns 0 if equal.
(other: String) => Number
contains¶
Check if other is present in the string.
(other: String) => Boolean
startsWith¶
Check if the string is prefixed with other.
(other: String) => Boolean
endsWith¶
Check if the string is suffixed with other.
(other: String) => Boolean
indexOf¶
Position of substring in the string. Returns -1 if not present.
(substring: String) => Number
substring¶
Returns a substring between start and end.
(start: Number, end: Number) => String
replaceFirst¶
Replaces first substring with with.
(pattern: String, with: String) => String
replaceAll¶
Replaces all substring with with.
(pattern: String, with: String) => String
replaceFirstMapped¶
Replaces first substring with value returned by with.
(pattern: String, mapper: (String) => String) => String
replaceAllMapped¶
Replaces all substring with value returned by with.
(pattern: String, mapper: (String) => String) => String
trim¶
Removes all whitespaces at the ends.
() => String
trimLeft¶
Removes all whitespaces at the start.
() => String
trimRight¶
Removes all whitespaces at the end.
() => String
padLeft¶
Pads using with at the start.
(length: Number, with: String) => String
padRight¶
Pads using with at the end.
(length: Number, with: String) => String
split¶
Splits the string at splitters.
(splitter: String) => List<String>
codeUnitAt¶
Returns code-unit at index.
(index: Number) => String
toCodeUnits¶
Returns code-units of the string.
() => List<Number>
toLowerCase¶
Returns the string in lowercase.
() => String
toUpperCase¶
Returns the string in uppercase.
() => String
format¶
Returns the formatted string. Example: "{} {1}".format(["Hello", "World"]), "{hello} {world}".format({ hello: "Hello", world: "World" }) returns Hello World
(env: Object | List<Any>) => String