String
Definitions
Abbreviate the string s if it exceeds the width w.
If the length of s exceeds w and w >= 3 then s is truncated and the first
three characters are replaced with ellipses.
If the length of s exceeds w and w < 3 then the empty string is returned.
Abbreviate the string s if it exceeds the width w.
If the length of s exceeds w and w >= 3 then s is truncated and the last
three characters are replaced with ellipses.
If the length of s exceeds w and w < 3 then the empty string is returned.
Find the first instance of substr in string s, return a pair of the
prefix of string s up to substr and the rest of string s including substr.
Find the last instance of substr in string s, return a pair of the
initial string including substr and suffix from substr.
Center the string s by padding with the supplied char c on both sides to fit the width w.
If the length of the string exceeds the given width, the string will be returned unchanged.
Requiring an uneven number of spaces, the string will be left biased,
e.g String.center(4, '_', "a") -> "_a__".
Returns the code point at position i in the string s.
Return the common prefix of strings s1 and s2.
Returns the empty string if s1 and s2 do not share a common prefix.
Return the common suffix of strings s1 and s2.
Returns the empty string if s1 and s2 do not share a common suffix.
Returns true if and only if substr is an infix of s.
Count the occurrences of substr in string s.
Drop the first n characters of string s from the left.
If n extends past the end of string s, return the empty string.
Drop the last n characters of string s from the right.
If n is greater than the length of string s, return the empty string.
Returns the middle of string s after dropping all the characters
from both ends that satisfy the predicate f.
The function f must be pure.
Returns the tail of string s after dropping all the initial chars
that satisfy the predicate f.
The function f must be pure.
Returns the front of string s after dropping all the characters
from the right end that satisfy the predicate f.
The function f must be pure.
Returns true if the string s ends with the string suffix.
Returns true if and only if at least one char in s satisfies the predicate f.
Returns false if s is empty.
Optionally returns the position of the first character in x satisfying f.
Returns None if no character in s satisfies f.
Optionally return the position of the first character in s satisfying f, reading right to left.
If nothing satisfies f return None.
Returns the positions of the all the elements in s satisfying f.
Applies f to a start value x and all elements in s going from left to right.
Accumulates the result of applying f pairwise to the elements of s and t
starting with the initial value x and going from left to right.
Applies f to a start value x and all elements in s` going from right to left.
Accumulates the result of applying f pairwise to the elements of s and t
starting with the initial value x and going from right to left.
Returns true if and only if all chars in s satisfy the predicate f.
Returns true if s is empty.
Returns a string from the given vector of UTF-8 bytes v.
Returns the character at position i in the string s.
Throws StringIndexOutOfBoundsException if the index is out of bounds.
Indent every line in string s by n spaces. n must be greater than 0.
If the string s in nonempty, the returned string normalizes line
termination characters and adds a line terminator to the last line
of the string if it does not already end with a newline.
If the string s is empty, then the empty string is returned.
Return the index of the first occurrence of substr in s from the left.
If substr is not present in s return None.
If substr is the empty string return None.
def indexOfLeftWithOffset(substr: { substr = String }, offset: { offset = Int32 }, s: String): Option[Int32]§ SourceThis is indexOfLeft with a start offset.
Returns None if substr is the empty string.
Return the index of the first occurrence of substr in s from the right.
If substr is not present in s return None.
If substr is the empty string return None.
def indexOfRightWithOffset(substr: { substr = String }, offset: { offset = Int32 }, s: String): Option[Int32]§ SourceThis is indexOfRight with a start offset.
Returns None if substr is the empty string.
Returns the positions of the all the occurrences of substr in s.
Returns an empty vector if substr is the empty string.
Build a string of length len by applying f to the successive indices.
Concatenate a list of strings into a single string, inserting the separator sep between
each pair of strings.
Concatenate a list of strings into a single string, inserting the separator sep between
each pair of strings.
Returns true if and only if all chars in s are ascii characters.
Returns true if s is empty.
Returns true if the entire string s is matched by the regular expression regex.
Note - use isSubmatch to search for a substring.
Returns true if the string s is matched by the regular expression regex at any point.
Returns true if and only if all chars in s are white space characters.
Returns true if s is empty.
Build a string by applying f to the initial char x.
f should return Some(c1) to signal a new char c1 (which also becomes the next input to f).
f should return None to signal the end of building the string.
Calculate the Levenshtein distance between the strings s and t.
The answer is the number deletions, insertions or substitutions needed to turn
string s into string t.
Split the string s into an array of lines, breaking on newline.
Newline is recognized as any Unicode linebreak sequence including Windows (carriage return, line feed) or Unix (line feed).
Returns the result of applying f to every character in s.
Returns the result of applying f to every character in s along with that character's index.
Optionally return the character at position i in the string s.
Optionally returns the code point at position i in the string s.
Pad the string s at the left with the supplied char c to fit the width w.
Pad the string s at the right with the supplied char c to fit the width w.
Returns s with the n elements starting at index i replaced with the elements of sub.
If any of the indices i, i+1, i+2, ... , i+n-1 are out of range in s then no patching is done at these indices.
If s becomes depleted then no further patching is done.
If patching occurs at index i+j in s, then the element at index j in sub is used.
Returns a string with the string s repeated n times.
Returns the empty string if n < 0.
Returns s with every match of the substring src replaced by the string dst.
Returns s with every match of the character src replaced by the character dst.
Returns s with the first match of the regular expression regex replaced by the string to.
Returns s with every match of the regular expression regex replaced by the string to.
Rotate the contents of string s by n steps to the left.
Rotate the contents of string s by n steps to the right.
Returns the substring of s from index b (inclusive) to index e (exclusive).
If b or e are out-of-bounds, return the empty string.
Get the substring of s to the left of index end (exclusive).
sliceLeft == slice(0 , e, s)
Get the substring of s to the right starting at index start (inclusive).
sliceRight == slice(start , length(s), s)
Splits the string s around matches of the regular expression regex.
Split the string s at the position n returning the left and
right (inclusive n) parts.
If n exceeds the length of string s, return the whole string
paired with the empty string. Symmetrically for n less than 0.
Split the string s on matches of substr.
Returns true if the string s starts with the string prefix.
Strip every indented line in string s by n spaces. n must be greater than 0.
Note, tabs are counted as a single space.
If the string s in nonempty, the returned string normalizes line
termination characters and adds a line terminator to the last line
of the string if it does not already end with a newline.
If the string s is empty, then the empty string is returned.
For every line in string s, strip a leading prefix consisting of
blanks or control characters followed by | from the line, if
such a prefix exists.
For every line in string s, strip a leading prefix consisting of
blanks or control characters followed by margin from the line, if
such a prefix exists.
Returns Some(suffix) of string s if its prefix matches substr.
Returns Some(prefix) of string s if its suffix matches substr.
Take the first n characters of string s from the left.
If n extends past the end of string s, return all the characters
of s.
Take the last n characters of string s from the right.
If n is greater than the length of string s, return all the characters
of s.
Returns the initial prefix of string s where all the chars satisfy
the predicate f.
The function f must be pure.
Returns the suffix of string s where all the characters satisfy
the predicate f.
The function f must be pure.
Returns the given string s as an array of characters.
Split the string s into chunks of length k, the last chunk may be smaller than k.
k should be greater than 0.
Compile the regular expression regex into a Regex object (internally
a Regex is java.util.regex.Pattern).
Returns Err if the regex is ill-formed and cannot be compiled.
The syntax of regular expressions is the same as Java, see the JDK Javadocs
of the class util.regex.Pattern for reference.
Warning: It is strongly recommended to use a Regex literal instead of toRegex.
Regex literals are checked at compile time.
Compile the regular expression regex into a Regex with the supplied flags.
Returns Err if the regex is ill-formed and cannot be compiled.
Warning: It is strongly recommended to use a Regex literal instead of toRegexWithFlags.
Regex literals are checked at compile time. See the JDK documentation of
java.util.regex.Pattern for guidance on enabling flags with embedded flag expressions.
Returns a copy of the string s without trailing and leading whitespaces.
Returns a new empty string if there is no characters in s.
Returns string s with all trailing space characters removed.
Build a string from the seed value x applying the function f until f returns None.
Build a string from the seed value x applying the function f until f returns None.
This is a version of unfold where f generates substrings rather than chars.
Build a string by applying the function next to (). next is expected to encapsulate
a stateful resource such as a file handle that can be iterated.
next should return Some(s) to signal a new substring s.
next should return None to signal the end of building the string.
Build a string by applying the function next to (). next is expected to encapsulate
a stateful resource such as a file handle that can be iterated.
next should return Some(c) to signal a new char c.
next should return None to signal the end of building the string.
Join the list of strings a separating each pair of strings and
ending the result string with the system dependent line separator.
Join the array of strings l separating each pair of strings with a
single space character.
Returns s with the element at index i replaced by a.
Returns s if i < 0 or i > length(xs)-1.
Split the string s into an list of words, dividing on one or more white space characters.
Leading and trailing spaces are trimmed.
Wrap the string s into lines that are each at most as long as w, breaking on whitespace.
If a line contains a single word that exceeds the length of w, the word will be broken.
Returns an array where the element at index i is (x, y) where
x is the element at index i in a and y is the element at index i in b.
If either a or b becomes depleted, then no further elements are added to the resulting array.
Returns a string where the element at index i is f(x, y) where
x is the element at index i in a and y is the element at index i in b.
If either a or b becomes depleted, then no further elements are added to the resulting array.