Expand description
String case-conversion helpers.
All functions are pure and allocation-free when the input already matches the target convention.
Functionsยง
- char_at
- Get character at index.
- contains
- Check if string contains needle.
- contains_
all - Check if string contains all needles.
- doesnt_
contain - Check if string does NOT contain needle.
- ends_
with - Check if string ends with needle.
- ensure_
start - Ensure string starts with the given value.
- escape_
html - Escape HTML special characters.
- finish
- Ensure string ends with the given value.
- invert_
case - Invert the case of a string.
- is_
alphanumeric - Check if string contains only alphanumeric characters.
- is_
ascii - Check if string contains only ASCII characters.
- is_
empty - Check if string is empty (after trimming).
- is_json
- Check if string is a valid JSON string.
- is_ulid
- Check if string is a valid ULID.
- is_url
- Check if string is a valid URL.
- is_uuid
- Check if string is a valid UUID.
- lcfirst
- Convert first character of string to lowercase.
- length
- Return the character count (not byte count).
- mask
- Mask characters from
indexonward with the given character. - pad_
both - Pad string to length on both sides.
- pad_
left - Pad string to length on the left.
- pad_
right - Pad string to length on the right.
- password
- Generate a secure password with letters, digits, and optionally symbols.
- pluralize
- Return a naive English plural of
word. - position
- Find position of needle in string.
- pretty_
duration - Convert nanoseconds to human-readable duration string.
- random
- Generate a cryptographically secure random string of given length. Uses URL-safe base64 encoding for the result.
- repeat
- Repeat a string
timestimes. - replace_
first - Replace first occurrence of
fromwithto. - replace_
last - Replace last occurrence of
fromwithto. - reverse
- Reverse a string.
- slug
- Convert a string to a URL-safe slug with the given separator.
- squish
- Collapse consecutive whitespace to single spaces and trim edges.
- starts_
with - Check if string starts with needle.
- substr_
count - Count occurrences of substring.
- to_
base64 - Convert string to base64 encoding.
- to_
camel_ case - Convert a string to
camelCase. - to_
dot_ case - Convert a string to
dot.case. - to_
headline - Convert a string to
Title Case(alias for to_title_case). - to_
kebab_ case - Convert a string to
kebab-case. - to_
lower - Convert a string to lowercase.
- to_
no_ case - Convert a string to
noCase(strips all casing). - to_
pascal_ case - Convert a string to
PascalCase. - to_
screaming_ snake - Convert a string to
SCREAMING_SNAKE_CASE. - to_
sentence_ case - Convert a string to
Sentence case. - to_
snake_ case - Convert a string to
snake_case. - to_
title_ case - Convert a string to
Title Case. - to_
upper - Convert a string to uppercase.
- truncate
- Truncate
sto at mostmaxcharacters, appending"..."if truncation occurs. - ucfirst
- Convert first character of string to uppercase.
- unwrap
- Remove prefix and suffix if present.
- word_
count - Return the word count.
- wrap
- Wrap a string with prefix and suffix.