gossamer/string

Values

pub fn at(
  string: String,
  index index: Int,
) -> Result(String, Nil)
pub fn char_code_at(
  string: String,
  index index: Int,
) -> Result(Int, Nil)
pub fn code_point_at(
  string: String,
  index index: Int,
) -> Result(Int, Nil)
pub fn concat(string: String, and other: String) -> String
pub fn ends_with(string: String, suffix suffix: String) -> Bool
pub fn ends_with_within(
  string: String,
  suffix suffix: String,
  within length: Int,
) -> Bool
pub fn from_char_code(code: Int) -> String
pub fn from_char_codes(codes: List(Int)) -> String
pub fn from_code_point(code: Int) -> Result(String, String)

Returns an error if the code point is invalid.

pub fn from_code_points(
  codes: List(Int),
) -> Result(String, String)

Returns an error if any code point is invalid.

pub fn includes(in string: String, search search: String) -> Bool
pub fn includes_from(
  in string: String,
  search search: String,
  from position: Int,
) -> Bool
pub fn index_of(in string: String, search search: String) -> Int
pub fn index_of_from(
  in string: String,
  search search: String,
  from position: Int,
) -> Int
pub fn is_well_formed(string: String) -> Bool
pub fn last_index_of(
  in string: String,
  search search: String,
) -> Int
pub fn last_index_of_from(
  in string: String,
  search search: String,
  from position: Int,
) -> Int
pub fn length(of string: String) -> Int

Returns the number of UTF-16 code units. This differs from gleam/string.length which counts grapheme clusters.

pub fn locale_compare(
  string: String,
  to other: String,
) -> order.Order
pub fn normalize(string: String) -> String

Returns the NFC-normalized form of the string.

pub fn normalize_with(
  string: String,
  form form: normalization_form.NormalizationForm,
) -> String
pub fn pad_end(
  string: String,
  to target_length: Int,
  with pad: String,
) -> String

Pads the end to reach target_length UTF-16 code units. This differs from gleam/string.pad_end which counts grapheme clusters.

pub fn pad_start(
  string: String,
  to target_length: Int,
  with pad: String,
) -> String

Pads the start to reach target_length UTF-16 code units. This differs from gleam/string.pad_start which counts grapheme clusters.

pub fn repeat(string: String, times times: Int) -> String
pub fn replace(
  in string: String,
  pattern pattern: String,
  with replacement: String,
) -> String

Replaces the first occurrence only. Use replace_all to replace every occurrence.

pub fn replace_all(
  in string: String,
  pattern pattern: String,
  with replacement: String,
) -> String
pub fn slice(
  string: String,
  from start: Int,
  to end: Int,
) -> String
pub fn split(
  string: String,
  on separator: String,
) -> List(String)
pub fn split_with_limit(
  string: String,
  on separator: String,
  limit limit: Int,
) -> List(String)
pub fn starts_with(string: String, prefix prefix: String) -> Bool
pub fn starts_with_from(
  string: String,
  prefix prefix: String,
  from position: Int,
) -> Bool
pub fn substring(
  string: String,
  from start: Int,
  to end: Int,
) -> String
pub fn to_locale_lower_case(string: String) -> String
pub fn to_locale_upper_case(string: String) -> String
pub fn to_lower_case(string: String) -> String
pub fn to_upper_case(string: String) -> String
pub fn to_well_formed(string: String) -> String
pub fn trim(string: String) -> String
pub fn trim_end(string: String) -> String
pub fn trim_start(string: String) -> String
Search Document