glimr/utils/string

String Utilities

Helper functions for string manipulation beyond what the standard library provides. Includes pluralization and other common string transformations.

Values

pub fn is_alphanumeric(char: String) -> Bool

Checks if a character is alphanumeric or underscore. Returns true for letters a-z, A-Z, digits 0-9, and underscore. Used for validating identifier characters.

Example:

string.is_alphanumeric("A") // True
string.is_alphanumeric(":") // False
pub fn is_letter(char: String) -> Bool
pub fn is_lowercase_letter(char: String) -> Bool
pub fn is_uppercase_letter(char: String) -> Bool
pub fn is_whitespace(char: String) -> Bool
pub fn pluralize(word: String) -> String

Simple pluralization of English words. Handles common cases like words ending in ‘s’, ‘x’, ‘z’, ‘ch’, ‘sh’ (add ‘es’), consonant + ‘y’ (change to ‘ies’), and default (add ‘s’).

Example:

string.pluralize("user")     // => "users"
string.pluralize("category") // => "categories"
string.pluralize("box")      // => "boxes"
string.pluralize("match")    // => "matches"
Search Document