THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
Undocumented
| Method | __getitem__ |
Return a substring or character by index or slice. |
| Method | __str__ |
Return the string representation of the object. |
| Method | after |
Return the substring after the first occurrence of a value. |
| Method | after |
Return the substring after the last occurrence of a value. |
| Method | apa |
Convert to APA-style title case. |
| Method | append |
Append one or more string values to the end of the string. |
| Method | ascii |
Transliterate to ASCII using Unicode normalization. |
| Method | basename |
Return the trailing name component of the path. |
| Method | before |
Return the substring before the first occurrence of a value. |
| Method | before |
Return the substring before the last occurrence of a value. |
| Method | between |
Return substring between two delimiters. |
| Method | between |
Return the substring between the first pair of delimiters. |
| Method | camel |
Convert the string to camel case. |
| Method | char |
Return the character at a given index. |
| Method | chop |
Remove the given string(s) from the end if present. |
| Method | chop |
Remove the given string(s) from the start if present. |
| Method | contains |
Check if the string contains any of the given values. |
| Method | contains |
Check if the string contains all specified substrings. |
| Method | convert |
Convert string case using specified mode. |
| Method | decrypt |
Decrypt the string using a placeholder implementation. |
| Method | deduplicate |
Replace consecutive occurrences of a character with a single instance. |
| Method | dirname |
Return the parent directory path. |
| Method | doesnt |
Determine if the string doesn't contain any given substring. |
| Method | doesnt |
Determine if string doesn't end with any given substring. |
| Method | doesnt |
Determine if the string doesn't start with any given substring. |
| Method | encrypt |
Encrypt the string using the Crypt facade. |
| Method | ends |
Determine if the string ends with any of the given substrings. |
| Method | exactly |
Return True if the string exactly matches the given value. |
| Method | excerpt |
Extract an excerpt containing the first occurrence of a phrase. |
| Method | explode |
Split the string into a list using a delimiter. |
| Method | finish |
Ensure the string ends with a single instance of the given value. |
| Method | from |
Decode the string from Base64. |
| Method | hash |
Hash the string using the specified algorithm. |
| Method | headline |
Convert to headline case. |
| Method | is |
Check if all characters are alphanumeric. |
| Method | is |
Check if all characters in the string are alphabetic. |
| Method | is |
Check if the string contains only 7-bit ASCII characters. |
| Method | is |
Check if all characters in the string are decimal characters. |
| Method | is |
Check if all characters are digits. |
| Method | is |
Check if the string is empty. |
| Method | is |
Check if the string is a valid Python identifier. |
| Method | is |
Check if the string is valid JSON. |
| Method | is |
Check if all cased characters in the string are lowercase. |
| Method | is |
Determine if the string matches any regular expression pattern. |
| Method | is |
Return True if the string is not empty. |
| Method | is |
Check if all characters in the string are numeric. |
| Method | is |
Check if the string matches any of the given patterns. |
| Method | is |
Return True if all characters in the string are printable. |
| Method | is |
Determine if the string contains only whitespace characters. |
| Method | is |
Check if the string is titlecased. |
| Method | is |
Check if the string is a valid ULID. |
| Method | is |
Check if all cased characters in the string are uppercase. |
| Method | is |
Determine if the string is a valid URL. |
| Method | is |
Determine if the string is a valid UUID. |
| Method | json |
Convert the object to a string when JSON encoded. |
| Method | kebab |
Convert the string to kebab case. |
| Method | lcfirst |
Convert the first character of the string to lowercase. |
| Method | length |
Return the number of characters in the string. |
| Method | limit |
Limit the string to a maximum number of characters. |
| Method | lower |
Convert to lowercase. |
| Method | l |
Remove leading characters from the string. |
| Method | ltrim |
Remove leading characters from the string. |
| Method | mask |
Mask a portion of the string with a repeated character. |
| Method | match |
Return the first substring matching the given regular expression pattern. |
| Method | match |
Find all substrings matching the given regular expression pattern. |
| Method | md5 |
Compute the MD5 hash of the string. |
| Method | new |
Append newline characters to the end of the string. |
| Method | numbers |
Remove all non-numeric characters from the string. |
| Method | offset |
Determine if the given offset exists in the string. |
| Method | offset |
Get the character at the specified offset. |
| Method | pad |
Pad both sides of the string to a specified total length. |
| Method | pad |
Pad the left side of the string to a specified total length. |
| Method | pad |
Pad the right side of the string to a specified total length. |
| Method | parse |
Parse a Class@method style callback into class and method. |
| Method | pascal |
Convert the string to PascalCase. |
| Method | pipe |
Pass the string through the given callback and return the result. |
| Method | plural |
Get the plural form of an English word. |
| Method | plural |
Pluralize the last word of an English Pascal case string. |
| Method | plural |
Pluralize the last word of an English, studly caps case string. |
| Method | position |
Find the position of the first occurrence of a substring. |
| Method | prepend |
Prepend values to the beginning of the string. |
| Method | remove |
Remove all occurrences of specified substrings from the string. |
| Method | repeat |
Repeat the string a specified number of times. |
| Method | replace |
Replace occurrences of substrings with replacements. |
| Method | replace |
Replace a substring sequentially with elements from a list. |
| Method | replace |
Replace the last occurrence of a value at the end of the string. |
| Method | replace |
Replace the first occurrence of a substring with a replacement. |
| Method | replace |
Replace the last occurrence of a substring with a replacement. |
| Method | replace |
Replace pattern matches in the string using regular expressions. |
| Method | replace |
Replace the first occurrence of a value at the start of the string. |
| Method | reverse |
Reverse the string. |
| Method | r |
Remove trailing characters from the string. |
| Method | rtrim |
Remove trailing characters from the string. |
| Method | scan |
Parse input from a string according to a format pattern. |
| Method | sha1 |
Compute the SHA1 hash of the string. |
| Method | sha256 |
Generate a SHA256 hash of the string. |
| Method | singular |
Get the singular form of an English word. |
| Method | slug |
Generate a URL-friendly slug from the string. |
| Method | snake |
Convert the string to snake_case using the specified delimiter. |
| Method | split |
Split the string by a regular expression or by length. |
| Method | squish |
Normalize whitespace in the string. |
| Method | start |
Ensure the string starts with a single instance of the given prefix. |
| Method | starts |
Determine if the string starts with any of the given substrings. |
| Method | strip |
Remove HTML and PHP tags from the string. |
| Method | studly |
Convert to StudlyCase (PascalCase). |
| Method | substr |
Return the portion of the string specified by start and length parameters. |
| Method | substr |
Count the number of substring occurrences in the string. |
| Method | substr |
Replace text within a portion of a string. |
| Method | swap |
Swap multiple keywords in a string with other keywords. |
| Method | swap |
Swap the case of each character in the string. |
| Method | take |
Take a specified number of characters from the start or end. |
| Method | tap |
Call the callback with the string and return the string. |
| Method | test |
Test whether the string matches a regular expression pattern. |
| Method | title |
Convert the string to title case. |
| Method | to |
Encode the string as Base64. |
| Method | to |
Convert to a boolean value. |
| Method | to |
Convert string to a datetime object. |
| Method | to |
Convert the string to a float. |
| Method | to |
Escape HTML entities in the string. |
| Method | to |
Convert the string to an integer. |
| Method | transliterate |
Transliterate a string to its closest ASCII representation. |
| Method | trim |
Trim characters from both ends of the string. |
| Method | ucfirst |
Capitalize the first character of the string. |
| Method | ucsplit |
Split the string by uppercase characters. |
| Method | unwrap |
Remove the specified prefix and suffix from the string. |
| Method | upper |
Convert all characters to uppercase. |
| Method | value |
Return the string value. |
| Method | when |
Execute the given callback if condition is true. |
| Method | when |
Execute callback if the string contains a given substring. |
| Method | when |
Execute callback if the string contains all specified substrings. |
| Method | when |
Execute callback if the string does not end with the given substring(s). |
| Method | when |
Execute callback if the string does not start with the given substring(s). |
| Method | when |
Execute callback if the string is empty. |
| Method | when |
Execute the callback if the string ends with the given substring(s). |
| Method | when |
Execute callback if the string exactly matches the given value. |
| Method | when |
Execute the callback if the string matches the given pattern. |
| Method | when |
Execute the callback if the string is 7-bit ASCII. |
| Method | when |
Execute the callback if the string is a valid ULID. |
| Method | when |
Execute the callback if the string is a valid UUID. |
| Method | when |
Execute the callback if the string is not empty. |
| Method | when |
Execute callback if string does not exactly match the given value. |
| Method | when |
Execute callback if the string starts with a given substring. |
| Method | when |
Execute callback if the string matches the given regular expression. |
| Method | word |
Count words in the string. |
| Method | words |
Limit the string to a maximum number of words. |
| Method | word |
Wrap text to a specified line width. |
| Method | wrap |
Wrap the string with a prefix and suffix. |
| Method | z |
Pad the string with leading zeros to a given width. |
| Class Variable | __slots__ |
Undocumented |
Return a substring or character by index or slice.
| Parameters | |
key:int or slice | Index or slice to retrieve. |
| Returns | |
Stringable | Stringable instance for the selected item(s). |
Return the substring after the first occurrence of a value.
| Parameters | |
search:str | Substring to search for in the current string. |
| Returns | |
Stringable | New Stringable containing the substring after the first occurrence of the search string, or the original string if not found. |
Return the substring after the last occurrence of a value.
| Parameters | |
search:str | Substring to search for within the current string. |
| Returns | |
Stringable | New Stringable containing the substring after the last occurrence of the search string, or the original string if not found. |
Convert to APA-style title case.
| Parameters | |
| Returns | |
Stringable | A new Stringable instance in APA title case. |
Append one or more string values to the end of the string.
| Parameters | |
*values:str | One or more string values to append. |
| Returns | |
Stringable | A new Stringable instance with all provided values appended. |
Transliterate to ASCII using Unicode normalization.
Uses Unicode normalization to remove accents and non-ASCII characters.
| Returns | |
Stringable | A new Stringable instance containing only ASCII characters. |
Return the trailing name component of the path.
| Parameters | |
suffix:str, optional | Suffix to remove from the basename. Default is "". |
| Returns | |
Stringable | A new Stringable instance containing the basename with the suffix removed if present. |
Return the substring before the first occurrence of a value.
| Parameters | |
search:str | Substring to search for within the current string. |
| Returns | |
Stringable | New Stringable instance containing the substring before the first occurrence of the search string, or the original string if not found. |
Return the substring before the last occurrence of a value.
Searches for the last occurrence of the specified substring and returns everything before it. If the substring is not found, returns the original string unchanged.
| Parameters | |
search:str | Substring to search for within the current string. |
| Returns | |
Stringable | New Stringable instance containing the substring before the last occurrence of the search string, or the original string if not found. |
Return substring between two delimiters.
| Parameters | |
fromstr | Starting delimiter. |
tostr | Ending delimiter. |
| Returns | |
Stringable | New Stringable containing text between delimiters, or empty if not found. |
Return the substring between the first pair of delimiters.
| Parameters | |
fromstr | Starting delimiter. |
tostr | Ending delimiter. |
| Returns | |
Stringable | Stringable containing text between the first pair of delimiters, or an empty Stringable if not found. |
Convert the string to camel case.
| Parameters | |
| Returns | |
Stringable | A new Stringable instance in camelCase. |
Remove the given string(s) from the end if present.
| Parameters | |
needle:str | list[str] | String or list of strings to remove from the end. |
| Returns | |
Stringable | New Stringable with the needle removed from the end if present. |
Remove the given string(s) from the start if present.
| Parameters | |
needle:str | list[str] | String or list of strings to remove from the start. |
| Returns | |
Stringable | New Stringable with the needle removed from the start if present. |
Check if the string contains any of the given values.
| Parameters | |
needles:str | Iterable[str] | Value or values to search for within the string. |
ignorebool, optional | If True, perform case-insensitive search. Default is False. |
| Returns | |
bool | True if the string contains any of the needle values, otherwise False. |
| Raises | |
TypeError | If needles is not a string or an iterable of strings. |
Convert string case using specified mode.
| Parameters | |
mode:int | None, optional | Case conversion mode: 0 or None - casefold (default) 1 - uppercase 2 - lowercase 3 - titlecase |
| Returns | |
Stringable | New Stringable instance with converted case. |
Decrypt the string using a placeholder implementation.
This is a placeholder. In a real implementation, use a proper decryption library such as cryptography.
| Returns | |
Stringable | The decrypted string as a Stringable instance. |
Replace consecutive occurrences of a character with a single instance.
| Parameters | |
character:str, optional | Single character string to deduplicate. Default is a space. |
| Returns | |
Stringable | Stringable with consecutive characters replaced by a single instance. |
Return the parent directory path.
| Parameters | |
levels:int, optional | Number of directory levels to ascend. Defaults to 1. |
| Returns | |
Stringable | Stringable instance containing the parent directory path. |
Determine if the string doesn't contain any given substring.
| Parameters | |
needles:str | list[str] | The substring(s) to search for within the string. |
ignorebool, optional | If True, perform case-insensitive search. Default is False. |
| Returns | |
bool | True if the string doesn't contain any of the needle values, otherwise False. |
| Raises | |
TypeError | If needles is not a string or list of strings, or if ignore_case is not a boolean. |
Encrypt the string using the Crypt facade.
This is a placeholder. In a real implementation, use a proper encryption library such as cryptography.
| Returns | |
Stringable | The encrypted string as a Stringable instance. |
Extract an excerpt containing the first occurrence of a phrase.
| Parameters | |
phrase:str, optional | Phrase to search for in the string. Default is "". |
options:dict | None, optional | Options for excerpt extraction. Supported keys: "radius": int, number of characters around the phrase (default 100). "omission": str, string to indicate omitted text (default "..."). |
| Returns | |
str | None | Excerpt containing the phrase and surrounding context, or None if not found. |
Ensure the string ends with a single instance of the given value.
| Parameters | |
cap:str | String to append as a cap if not already present. |
| Returns | |
Stringable | Stringable instance ending with the specified cap. |
Decode the string from Base64.
| Parameters | |
strict:bool, optional | If True, raise an exception on decode errors. Default is False. |
| Returns | |
Stringable | A new Stringable instance with Base64-decoded content. If decoding fails and strict is False, returns an empty Stringable. |
Hash the string using the specified algorithm.
| Parameters | |
algorithm:str | Hash algorithm name (md5, sha1, sha256, etc.) |
| Returns | |
Stringable | A new Stringable instance containing the hexadecimal hash. |
| Raises | |
ValueError | If the specified algorithm is not supported. |
Convert to headline case.
Splits the string into words and capitalizes the first letter of each word.
| Returns | |
Stringable | A new Stringable instance with each word capitalized. |
Check if all characters are alphanumeric.
| Returns | |
bool | True if all characters in the string are alphanumeric, otherwise False. |
Check if all characters in the string are alphabetic.
| Returns | |
bool | True if all characters are alphabetic, otherwise False. |
Check if the string contains only 7-bit ASCII characters.
| Returns | |
bool | True if the string is ASCII, otherwise False. |
Check if all characters in the string are decimal characters.
| Returns | |
bool | True if all characters are decimal, otherwise False. |
Check if all characters are digits.
| Returns | |
bool | True if all characters in the string are digits, otherwise False. |
Check if the string is a valid Python identifier.
| Returns | |
bool | True if the string is a valid identifier, otherwise False. |
Check if all cased characters in the string are lowercase.
| Returns | |
bool | True if all cased characters are lowercase, otherwise False. |
Return True if the string is not empty.
| Returns | |
bool | True if the string contains one or more characters, otherwise False. |
Check if all characters in the string are numeric.
| Returns | |
bool | True if all characters are numeric, otherwise False. |
Check if the string matches any of the given patterns.
| Parameters | |
pattern:str | list[str] | Pattern(s) to match, supports wildcards '*' and '?'. |
ignorebool, optional | If True, perform case-insensitive matching. Default is False. |
| Returns | |
bool | True if the string matches any pattern, otherwise False. |
| Raises | |
TypeError | If pattern is not a string or list of strings. |
TypeError | If ignore_case is not a boolean. |
ValueError | If the pattern list is empty. |
Return True if all characters in the string are printable.
| Returns | |
bool | True if all characters are printable, otherwise False. |
Determine if the string contains only whitespace characters.
| Returns | |
bool | True if the string contains only whitespace characters, otherwise False. |
Check if all cased characters in the string are uppercase.
| Returns | |
bool | True if all cased characters are uppercase, otherwise False. |
Determine if the string is a valid UUID.
| Parameters | |
version:int | str | None, optional | UUID version to validate (1-8), or "max" for any version up to 8. If None, any valid UUID version is accepted. |
| Returns | |
bool | True if the string is a valid UUID (and version, if specified), otherwise False. |
Convert the object to a string when JSON encoded.
This method is called when the Stringable object is being JSON serialized. It returns the string representation of the object for proper JSON encoding.
| Returns | |
str | The string representation for JSON serialization. |
Convert the first character of the string to lowercase.
| Returns | |
Stringable | A new Stringable instance with the first character in lowercase. |
int = 100, end: str = '...', *, preserve_words: bool = False) -> Stringable:
(source)
¶
Limit the string to a maximum number of characters.
| Parameters | |
limit:int, default 100 | Maximum number of characters allowed. |
end:str, default "..." | String to append if truncation occurs. |
preservebool, default False | If True, do not cut off words in the middle. |
| Returns | |
Stringable | New Stringable instance limited to the specified number of characters.
If truncation occurs, the end string is appended. |
Remove leading characters from the string.
| Parameters | |
chars:str | None, optional | Characters to remove from the beginning. If None, whitespace is removed. |
| Returns | |
Stringable | A new Stringable instance with leading characters removed. |
Remove leading characters from the string.
| Parameters | |
characters:str | None, optional | Characters to remove from the start. If None, whitespace is removed. |
| Returns | |
Stringable | A new Stringable instance with leading characters removed. |
Mask a portion of the string with a repeated character.
| Parameters | |
character:str | Character to use for masking. |
index:int | Starting index for masking. |
length:int | None, optional | Number of characters to mask. If None, mask to end of string. |
| Returns | |
Stringable | A new Stringable with the specified portion masked. |
Return the first substring matching the given regular expression pattern.
| Parameters | |
pattern:str | Regular expression pattern to search for. |
| Returns | |
Stringable | A new Stringable containing the first match, or an empty Stringable if no match is found. |
Compute the MD5 hash of the string.
| Returns | |
str | Hexadecimal string representing the MD5 hash of the input string. |
Append newline characters to the end of the string.
| Parameters | |
count:int, optional | Number of newline characters to append. Default is 1. |
| Returns | |
Stringable | A new Stringable instance with the specified number of newline characters appended. |
Remove all non-numeric characters from the string.
| Parameters | |
self:Stringable | The current string instance. |
| Returns | |
Stringable | A new Stringable containing only numeric characters. |
Get the character at the specified offset.
| Parameters | |
offset:int | Index of the character to retrieve. |
| Returns | |
str | Character at the given offset. |
| Raises | |
TypeError | If offset is not an integer. |
IndexError | If offset is out of bounds. |
Pad both sides of the string to a specified total length.
| Parameters | |
length:int | Total desired length of the resulting string. |
pad:str, optional | String to use for padding. Default is a single space. |
| Returns | |
Stringable | New Stringable instance with padding added to both sides. |
Pad the left side of the string to a specified total length.
| Parameters | |
length:int | Total desired length of the resulting string. |
pad:str, optional | String to use for padding, by default a single space. |
| Returns | |
Stringable | New Stringable instance with left padding added. |
Pad the right side of the string to a specified total length.
| Parameters | |
length:int | The total desired length of the resulting string. |
pad:str, optional | The string to use for padding, by default a single space. |
| Returns | |
Stringable | A new Stringable instance with right padding added. |
Parse a Class@method style callback into class and method.
| Parameters | |
default:str | None, optional | Default method name if not specified. Default is None. |
| Returns | |
list[str | None] | List containing [class_name, method_name]. |
Pass the string through the given callback and return the result.
| Parameters | |
callback:Callable | The callback function to apply to the string. |
| Returns | |
Stringable | A new Stringable instance containing the result of the callback. |
| Raises | |
TypeError | If the callback is not callable. |
int | list | Any = 2, *, prepend_count: bool = False) -> Stringable:
(source)
¶
Get the plural form of an English word.
| Parameters | |
count:int | list | Any, optional | Count to determine if plural is needed, by default 2 |
prependbool, optional | Whether to prepend the count, by default False |
| Returns | |
Stringable | A new Stringable with plural form |
Pluralize the last word of an English Pascal case string.
| Parameters | |
count:int | list | Any, optional | Count to determine if plural is needed. Default is 2. |
| Returns | |
Stringable | New Stringable with pluralized last word in PascalCase. |
Pluralize the last word of an English, studly caps case string.
| Parameters | |
count:int | list | Any, optional | Count to determine if plural is needed, by default 2 |
| Returns | |
Stringable | A new Stringable with pluralized last word in StudlyCase |
str, offset: int = 0, encoding: str | None = None) -> int | bool:
(source)
¶
Find the position of the first occurrence of a substring.
| Parameters | |
needle:str | Substring to search for. |
offset:int, optional | Starting index for the search. Default is 0. |
encoding:str | None, optional | String encoding for compatibility. Default is None. |
| Returns | |
int or bool | Index of the first occurrence of the substring, or False if not found. |
Prepend values to the beginning of the string.
| Parameters | |
*values:str | One or more string values to prepend to the current string. |
| Returns | |
Stringable | A new Stringable instance with all provided values prepended. |
| Raises | |
TypeError | If any value is not a string. |
Remove all occurrences of specified substrings from the string.
| Parameters | |
search:str | list[str] | Substring(s) to remove from the string. |
casebool, default True | If True, removal is case sensitive. |
| Returns | |
Stringable | New Stringable instance with specified substrings removed. |
Repeat the string a specified number of times.
| Parameters | |
times:int | Number of times to repeat the string. |
| Returns | |
Stringable | New Stringable instance with the string repeated the specified number of times. |
str | Iterable[ str], replace: str | Iterable[ str], *, case_sensitive: bool = True) -> Stringable:
(source)
¶
Replace occurrences of substrings with replacements.
| Parameters | |
search:str | Iterable[str] | Substring(s) to search for in the string. |
replace:str | Iterable[str] | Replacement string(s) for each search substring. |
casebool, optional | If True, perform case-sensitive replacement. Default is True. |
| Returns | |
Stringable | A new Stringable instance with the specified replacements applied. |
Replace a substring sequentially with elements from a list.
| Parameters | |
search:str | Substring to search for and replace. |
replace:list[str] | List of replacement strings to use sequentially. |
| Returns | |
Stringable | New Stringable instance with sequential replacements applied. |
Replace the last occurrence of a value at the end of the string.
| Parameters | |
search:str | String to search for at the end. |
replace:str | Replacement string. |
| Returns | |
Stringable | New Stringable instance with the end replaced if the search string is found, otherwise returns the original string. |
Replace the first occurrence of a substring with a replacement.
| Parameters | |
search:str | Substring to search for in the string. |
replace:str | Replacement string. |
| Returns | |
Stringable | New Stringable instance with the first occurrence replaced. |
Replace the last occurrence of a substring with a replacement.
| Parameters | |
search:str | Substring to search for in the string. |
replace:str | Replacement string. |
| Returns | |
Stringable | New Stringable instance with the last occurrence replaced. |
str | list[ str], replace: str | Callable, limit: int = -1) -> Stringable:
(source)
¶
Replace pattern matches in the string using regular expressions.
| Parameters | |
pattern:str | list[str] | Regular expression pattern(s) to search for. |
replace:str | Callable | Replacement string or callback function. |
limit:int, optional | Maximum number of replacements. Default is -1 (no limit). |
| Returns | |
Stringable | New Stringable instance with pattern matches replaced. |
Replace the first occurrence of a value at the start of the string.
| Parameters | |
search:str | String to search for at the start. |
replace:str | Replacement string. |
| Returns | |
Stringable | New Stringable with the start replaced if the search string is found. |
Remove trailing characters from the string.
| Parameters | |
chars:str | None, optional | Characters to remove from the end. If None, removes whitespace. |
| Returns | |
Stringable | A new Stringable instance with trailing characters removed. |
Remove trailing characters from the string.
| Parameters | |
characters:str | None, optional | Characters to trim from the end. If None, trims whitespace. |
| Returns | |
Stringable | New Stringable instance with trailing characters removed. |
Parse input from a string according to a format pattern.
Extracts values from the string using a simplified sscanf-like format string with %s (strings), %d (digits), and %f (floats) placeholders.
| Parameters | |
formatstr | Format string with placeholders (%s, %d, %f). |
| Returns | |
list[str] | List of parsed string values, or empty list if no matches found. |
| Raises | |
TypeError | If format_str is not a string. |
Compute the SHA1 hash of the string.
| Returns | |
str | Hexadecimal string representing the SHA1 hash of the input string. |
Generate a SHA256 hash of the string.
| Returns | |
str | Hexadecimal string representing the SHA256 hash of the input string. |
Get the singular form of an English word.
| Returns | |
Stringable | A new Stringable with singular form of the word. |
str = '-', dictionary: dict[ str, str] | None = None) -> Stringable:
(source)
¶
Generate a URL-friendly slug from the string.
| Parameters | |
separator:str, optional | Separator to use in the slug. Default is "-". |
dictionary:dict[str, str] | None, optional | Dictionary for character replacements. Default is {"@": "at"}. |
| Returns | |
Stringable | A new Stringable instance containing the URL-friendly slug. |
Convert the string to snake_case using the specified delimiter.
| Parameters | |
delimiter:str, optional | Delimiter to use for separation, by default "_". |
| Returns | |
Stringable | A new Stringable instance in snake_case. |
Split the string by a regular expression or by length.
| Parameters | |
pattern:str or int | Regular expression pattern or chunk length. |
limit:int, optional | Maximum number of splits. Default is -1 (no limit). |
flags:int, optional | Regular expression flags. Default is 0. |
| Returns | |
list of str | List of string segments after splitting. |
Normalize whitespace in the string.
Replace consecutive whitespace characters with a single space and trim leading and trailing whitespace.
| Returns | |
Stringable | Stringable instance with normalized whitespace. |
Ensure the string starts with a single instance of the given prefix.
| Parameters | |
prefix:str | The prefix to ensure at the start of the string. |
| Returns | |
Stringable | A new Stringable instance starting with the specified prefix. |
Remove HTML and PHP tags from the string.
| Parameters | |
allowedstr | None, optional | Tags that should not be stripped. Default is None. |
| Returns | |
Stringable | A new Stringable instance with tags removed. |
Convert to StudlyCase (PascalCase).
Replaces underscores, hyphens, and spaces with spaces, splits into words, capitalizes each word, and joins them without separators.
| Returns | |
Stringable | A new Stringable instance in StudlyCase. |
Return the portion of the string specified by start and length parameters.
| Parameters | |
start:int | Starting position for substring extraction. |
length:int | None, optional | Length of substring to extract. If None, extracts to end of string. Default is None. |
| Returns | |
Stringable | A new Stringable instance containing the extracted substring. |
| Raises | |
TypeError | If start is not an integer or length is not an integer or None. |
Count the number of substring occurrences in the string.
| Parameters | |
needle:str | The substring to count occurrences of. |
offset:int, optional | Starting position to begin the search. Default is 0. |
length:int | None, optional | Maximum length to search within. If None, searches to end. Default is None. |
| Returns | |
int | Number of non-overlapping occurrences of the needle substring. |
| Raises | |
TypeError | If needle is not a string, offset is not an integer, or length is not an integer or None. |
str | list[ str], offset: int | list[ int] = 0, length: int | list[ int] | None = None) -> Stringable:
(source)
¶
Replace text within a portion of a string.
| Parameters | |
replace:str | list[str] | Replacement string(s) |
offset:int | list[int], optional | Starting position(s), by default 0 |
length:int | list[int] | None, optional | Length(s) to replace, by default None |
| Returns | |
Stringable | A new Stringable with replaced text |
| Raises | |
TypeError | If replace is not a string or list of strings. |
TypeError | If offset is not an integer or list of integers. |
TypeError | If length is not an integer, list of integers, or None. |
ValueError | If any length value is negative. |
ValueError | If lists have incompatible lengths. |
Swap multiple keywords in a string with other keywords.
| Parameters | |
mapDict[str, str] | Dictionary mapping old values to new values. |
| Returns | |
Stringable | A new Stringable instance with swapped values. |
| Raises | |
TypeError | If map_dict is not a dictionary or contains non-string keys/values. |
Swap the case of each character in the string.
Converts uppercase characters to lowercase and lowercase characters to uppercase, leaving other characters unchanged.
| Parameters | |
| Returns | |
Stringable | New Stringable instance with all character cases swapped. |
Take a specified number of characters from the start or end.
| Parameters | |
limit:int | Number of characters to take. Negative values take from the end. |
| Returns | |
Stringable | A new Stringable containing the taken characters. |
Call the callback with the string and return the string.
| Parameters | |
callback:Callable[[Stringable], Any] | Function to execute with the string. |
| Returns | |
Stringable | The same Stringable instance. |
Convert the string to title case.
| Returns | |
Stringable | A new Stringable instance with each word capitalized. |
Encode the string as Base64.
| Returns | |
Stringable | A new Stringable instance containing the Base64-encoded string. |
Convert to a boolean value.
The string is considered True if it matches common truthy values such as "1", "true", "on", or "yes" (case-insensitive).
| Returns | |
bool | True if the string represents a truthy value, otherwise False. |
Convert the string to a float.
| Returns | |
float | Float representation of the string. |
| Raises | |
ValueError | If the string cannot be converted to a float. |
Escape HTML entities in the string.
Escapes special HTML characters in the string to ensure safe HTML output.
| Returns | |
Stringable | A new Stringable instance containing the HTML-escaped string. |
Convert the string to an integer.
| Parameters | |
base:int, optional | The base for conversion. Default is 10. |
| Returns | |
int | Integer representation of the string. |
| Raises | |
ValueError | If the string cannot be converted to an integer. |
Transliterate a string to its closest ASCII representation.
| Parameters | |
unknown:str, optional | Character to use for unknown characters. Default is "?". |
strict:bool, optional | Whether to be strict about transliteration. Default is False. |
| Returns | |
Stringable | A new Stringable with transliterated text. |
Trim characters from both ends of the string.
| Parameters | |
characters:str | None, optional | Characters to trim from both ends. If None, trims whitespace. |
| Returns | |
Stringable | New Stringable instance with specified characters trimmed. |
Capitalize the first character of the string.
| Returns | |
Stringable | A new Stringable instance with the first character in uppercase. |
Split the string by uppercase characters.
| Parameters | |
self:Stringable | The current string instance. |
| Returns | |
list of str | List of words split by uppercase characters, or the original string in a list if no split occurs. |
Remove the specified prefix and suffix from the string.
| Parameters | |
before:str | Prefix string to remove from the start. |
after:str | None, optional | Suffix string to remove from the end. If None, uses before. |
| Returns | |
Stringable | New Stringable instance with the specified prefix and suffix removed. |
Convert all characters to uppercase.
| Returns | |
Stringable | A new Stringable instance with all characters in uppercase. |
bool | Callable, callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute the given callback if condition is true.
| Parameters | |
condition:bool or callable | The condition to evaluate. |
callback:callable | The callback to execute if condition is true. |
default:callable or None, optional | The callback to execute if condition is false. Default is None. |
| Returns | |
Stringable | Result of callback execution or self. |
str | list[ str], callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute callback if the string contains a given substring.
| Parameters | |
needles:str | list[str] | Substring(s) to search for in the string. |
callback:Callable | Function to execute if the condition is True. |
default:Callable | None, optional | Function to execute if the condition is False. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
list[ str], callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute callback if the string contains all specified substrings.
| Parameters | |
needles:list[str] | Substrings to search for in the string. |
callback:Callable | Function to execute if all substrings are found. |
default:Callable | None, optional | Function to execute if not all substrings are found. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
str | list[ str], callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute callback if the string does not end with the given substring(s).
| Parameters | |
needles:str | list[str] | Substring(s) to check at the end of the string. |
callback:Callable | Function to execute if the condition is True. |
default:Callable | None, optional | Function to execute if the condition is False. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
str | list[ str], callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute callback if the string does not start with the given substring(s).
| Parameters | |
needles:str or list[str] | Substring(s) to check at the start of the string. |
callback:Callable | Function to execute if the condition is True. |
default:Callable | None, optional | Function to execute if the condition is False. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
Execute callback if the string is empty.
| Parameters | |
callback:Callable | Function to execute if the string is empty. |
default:Callable | None, optional | Function to execute if the string is not empty. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
str | list[ str], callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute the callback if the string ends with the given substring(s).
| Parameters | |
needles:str or list[str] | Substring(s) to check at the end of the string. |
callback:Callable | Function to execute if the condition is True. |
default:Callable | None, optional | Function to execute if the condition is False. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
str, callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute callback if the string exactly matches the given value.
| Parameters | |
value:str | Value to compare for an exact match. |
callback:Callable | Function to execute if the string matches exactly. |
default:Callable | None, optional | Function to execute if the string does not match exactly. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
str | list[ str], callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute the callback if the string matches the given pattern.
| Parameters | |
pattern:str or list of str | Pattern(s) to match against. |
callback:Callable | Function to execute if the string matches the pattern. |
default:Callable or None, optional | Function to execute if the string does not match the pattern. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute the callback if the string is 7-bit ASCII.
| Parameters | |
callback:Callable | Function to execute if the string is ASCII. |
default:Callable | None, optional | Function to execute if the string is not ASCII. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
Execute the callback if the string is a valid ULID.
| Parameters | |
callback:Callable | Function to execute if the string is a valid ULID. |
default:Callable | None, optional | Function to execute if the string is not a valid ULID. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
Execute the callback if the string is a valid UUID.
| Parameters | |
callback:Callable | Function to execute if the string is a valid UUID. |
default:Callable | None, optional | Function to execute if the string is not a valid UUID. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute the callback if the string is not empty.
| Parameters | |
callback:Callable | Function to execute if the string is not empty. |
default:Callable | None, optional | Function to execute if the string is empty. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
str, callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute callback if string does not exactly match the given value.
| Parameters | |
value:str | Value to compare for an exact match. |
callback:Callable | Function to execute if the string does not match exactly. |
default:Callable | None, optional | Function to execute if the string matches exactly. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
str | list[ str], callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute callback if the string starts with a given substring.
| Parameters | |
needles:str or list[str] | Substring(s) to check at the start of the string. |
callback:Callable | Function to execute if the condition is True. |
default:Callable | None, optional | Function to execute if the condition is False. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
str, callback: Callable, default: Callable | None = None) -> Stringable:
(source)
¶
Execute callback if the string matches the given regular expression.
| Parameters | |
pattern:str | Regular expression pattern to match. |
callback:Callable | Function to execute if the pattern matches. |
default:Callable | None, optional | Function to execute if the pattern does not match. Default is None. |
| Returns | |
Stringable | Result of callback execution or the original Stringable instance. |
Count words in the string.
| Parameters | |
characters:str | None, optional | Additional characters to treat as word separators. Default is None. |
| Returns | |
int | Number of words in the string. |
Limit the string to a maximum number of words.
| Parameters | |
words:int, optional | Maximum number of words to include. Default is 100. |
end:str, optional | String to append if truncation occurs. Default is '...'. |
| Returns | |
Stringable | New Stringable instance containing at most the specified number of words, with the end string appended if truncation occurs. |
int = 75, break_str: str = '\n', *, cut_long_words: bool = False) -> Stringable:
(source)
¶
Wrap text to a specified line width.
| Parameters | |
characters:int, optional | Maximum line width. Default is 75. |
breakstr, optional | String to insert at line breaks. |
cutbool, optional | If True, break long words. Default is False. |
| Returns | |
Stringable | New Stringable instance with wrapped text. |
Wrap the string with a prefix and suffix.
| Parameters | |
before:str | Prefix to prepend to the string. |
after:str | None, optional | Suffix to append to the string. If None, uses before. |
| Returns | |
Stringable | New Stringable instance with the string wrapped by prefix and suffix. |
Pad the string with leading zeros to a given width.
| Parameters | |
width:int | Total width of the resulting string. |
| Returns | |
Stringable | A new Stringable instance padded with leading zeros. |