Split a string into substrings using a predicate function, dropping any matching delimiters.
StrUtils Type Module
Returns the elements of a string before and after the first element matched by a predicate function.
Returns the elements of a string before and after the last element in the string matched by a predicate function.
capitalize : Str -> Str
Capitalize the first letter of a string. Lowercase the rest of it.
Convert all ASCII letters in the string to uppercase.
Convert all ASCII letters in the string to lowercase.
Pad the string with the given character on the left until it reaches the target length. Returns an Error if the string contains characters that are not printable ASCII. If the padding character is not printable ASCII, it will be replaced with a space.
expect pad_left("123", '_', 5) == Ok("__123")
expect pad_left("123", 127, 5) == Ok(" 123")
expect pad_left("🔥", ' ', 2) == Err(InvalidASCII)
Pad the string with the given character on the right until it reaches the target length. Returns an Error if the string contains characters that are not printable ASCII. If the padding character is not printable ASCII, it will be replaced with a space.
expect pad_right("123", '_', 5) == Ok("123__")
expect pad_right("123", 127, 5) == Ok("123 ")
expect pad_right("🔥", ' ', 2) == Err(InvalidASCII)