casefold

Values

pub const ascii_letters: String

ASCII letters (lower and uppercase).

pub const ascii_lowercase: String

ASCII lowercase letters.

pub const ascii_printable: String

All printable ASCII characters.

pub const ascii_punctuation: String

ASCII characters which are considered punctuation characters.

pub const ascii_uppercase: String

ASCII uppercase letters.

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 const digits: String

The string “0123456789”.

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 const hex_digits: String

The string “0123456789abcdefABCDEF”.

pub fn is_alnum(s: String) -> Bool

True if all graphemes in string are ASCII alphanumeric characters.

pub fn is_alnum_grapheme(g: String) -> Bool

True if the grapheme is an ASCII alphanumeric character.

pub fn is_alpha(s: String) -> Bool

True if all graphemes in string are ASCII letters.

pub fn is_alpha_grapheme(g: String) -> Bool

True if the grapheme is an ASCII letter.

pub fn is_ascii(s: String) -> Bool

True if all graphemes in string are ASCII characters.

pub fn is_binary(s: String) -> Bool

True if all graphems in string are ASCII binary digit characters (0 or 1), including an optional binary prefix (0b).

pub fn is_binary_grapheme(g: String) -> Bool

True if the grapheme is an ASCII binary digit character (0 or 7)

pub fn is_blank(s: String) -> Bool

True if the string contains only ASCII whitespace or if the string is empty.

pub fn is_decimal(s: String) -> Bool

True if all graphemes in string are ASCII decimal digit characters (0-9).

pub fn is_decimal_grapheme(g: String) -> Bool

True if the grapheme is an ASCII decimal digit character (0-9).

pub fn is_hex(s: String) -> Bool

True if all graphemes in string are ASCII hex digit characters (0-9, a-f, A-F), including an optional hex prefix (0x).

pub fn is_hex_grapheme(g: String) -> Bool

True if the grapheme is an ASCII hex digit character (0-7)

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 is_octal(s: String) -> Bool

True if all graphemes in string are ASCII octal digit characters (0-7), including an optional octal prefix (0o).

pub fn is_octal_grapheme(g: String) -> Bool

True if the grapheme is an ASCII octal digit character (0-7)

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 const oct_digits: String

The string “01234567”.

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_at(
  string s: String,
  at index: Int,
) -> #(String, String)

Splits a string in two before the given grapheme index.

If the string is not long enough to have the given index the before string will be the input string, and the after string will be empty.

A negative index works from the end of the string.

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.

✨ Search Document