casefold
Values
pub const ascii_punctuation: String
ASCII characters which are considered punctuation characters.
pub const ascii_whitespace: String
ASCII characters which are considered whitespace.
pub fn casefold(s: String) -> String
Converts a String to a case-agnostic comparable string.
casefold is preferred over string.lowercase when two
strings are to be compared for equality.
pub fn expand_tabs(s: String, tabstop: Int) -> String
Expand leading tabs with the given tabstop.
pub fn format(fmt: String, slots: List(String)) -> String
Format string
See also: format_named
Provides a basic string formatter. Does not handle type conversion, all values provided must be strings.
Values are inserted at {} slots in the format string. To include a literal { or }, use {{ or }}.
Example:
import gleam/io
import casefold.{format}
pub fn main() {
io.println(format("Hello, {}!", ["Joe"]))
}
pub fn format_named(
fmt: String,
slots: List(#(String, String)),
) -> String
Format string (key/value)
Provides a basic string formatter. Does not handle type conversion, all values provided must be strings.
Values are inserted at {key} slots in the format string. To include a literal { or }, use {{ or }}.
Example:
import gleam/io
import casefold.{format_named}
pub fn main() {
io.println(format_named("Hello, {name}!", [#("name", "Joe")]))
}
pub fn is_alnum(s: String) -> Bool
True if all graphemes in string are ASCII alphanumeric characters.
pub fn is_ascii(s: String) -> Bool
True if all graphemes in string are ASCII characters.
pub fn is_blank(s: String) -> Bool
True if the string contains only ASCII whitespace or if the string is empty.
pub fn is_hspaces(s: String) -> Bool
True if the string contains only spaces and/or tabs or if the string is empty.
pub fn jaro_similarity(first: String, second: String) -> Float
Returns a float between +0.0 and 1.0 representing the Jaro similarity between the given strings. Strings with a higher similarity will score closer to 1.0, with +0.0 meaning no similarity and 1.0 meaning an exact match.
pub fn pop(s: String) -> #(String, String)
Pops a grapheme off the front of the string.
Returns #(“”, “”) if the string is empty or any other error occurs (if the string is invalid).
pub fn split_lines(s: String) -> List(String)
Splits the input string into a list of lines with the line endings (\n or \r\n) removed. An empty string splits into an empty list.
pub fn split_words(s: String) -> List(String)
Splits the input string into a list of words. An empty string splits into an empty list.