pub struct Str;Implementations§
Source§impl Str
impl Str
Sourcepub fn after(subject: &str, search: &str) -> String
pub fn after(subject: &str, search: &str) -> String
Return the remainder of a string after the first occurrence of a given value
Sourcepub fn after_last(subject: &str, search: &str) -> String
pub fn after_last(subject: &str, search: &str) -> String
Return the remainder of a string after the last occurrence of a given value
Sourcepub fn transliterate(
string: &str,
unknown: Option<&str>,
strict: Option<bool>,
) -> String
pub fn transliterate( string: &str, unknown: Option<&str>, strict: Option<bool>, ) -> String
Transliterate a string to its closest ASCII representation
Sourcepub fn before(subject: &str, search: &str) -> String
pub fn before(subject: &str, search: &str) -> String
Get the portion of a string before the first occurrence of a given value
Sourcepub fn before_last(subject: &str, search: &str) -> String
pub fn before_last(subject: &str, search: &str) -> String
Get the portion of a string before the last occurrence of a given value
Sourcepub fn between(subject: &str, from: &str, to: &str) -> String
pub fn between(subject: &str, from: &str, to: &str) -> String
Get the portion of a string between two given values
Sourcepub fn between_first(subject: &str, from: &str, to: &str) -> String
pub fn between_first(subject: &str, from: &str, to: &str) -> String
Get the smallest possible portion of a string between two given values
Sourcepub fn char_at(subject: &str, index: isize) -> Option<char>
pub fn char_at(subject: &str, index: isize) -> Option<char>
Get the character at the specified index
Sourcepub fn chop_start(subject: &str, needles: &[&str]) -> String
pub fn chop_start(subject: &str, needles: &[&str]) -> String
Remove the given string(s) if it exists at the start of the haystack
Sourcepub fn chop_end(subject: &str, needles: &[&str]) -> String
pub fn chop_end(subject: &str, needles: &[&str]) -> String
Remove the given string(s) if it exists at the end of the haystack
Sourcepub fn contains(haystack: &str, needles: &[&str], ignore_case: bool) -> bool
pub fn contains(haystack: &str, needles: &[&str], ignore_case: bool) -> bool
Determine if a given string contains a given substring
Sourcepub fn contains_all(haystack: &str, needles: &[&str], ignore_case: bool) -> bool
pub fn contains_all(haystack: &str, needles: &[&str], ignore_case: bool) -> bool
Determine if a given string contains all array values
Sourcepub fn doesnt_contain(
haystack: &str,
needles: &[&str],
ignore_case: bool,
) -> bool
pub fn doesnt_contain( haystack: &str, needles: &[&str], ignore_case: bool, ) -> bool
Determine if a given string doesn’t contain a given substring
Sourcepub fn convert_case(string: &str, mode: CaseMode) -> String
pub fn convert_case(string: &str, mode: CaseMode) -> String
Convert the case of a string
Sourcepub fn deduplicate(string: &str, characters: &[char]) -> String
pub fn deduplicate(string: &str, characters: &[char]) -> String
Replace consecutive instances of a given character with a single character
Sourcepub fn ends_with(haystack: &str, needles: &[&str]) -> bool
pub fn ends_with(haystack: &str, needles: &[&str]) -> bool
Determine if a given string ends with a given substring
Sourcepub fn doesnt_end_with(haystack: &str, needles: &[&str]) -> bool
pub fn doesnt_end_with(haystack: &str, needles: &[&str]) -> bool
Determine if a given string doesn’t end with a given substring
Sourcepub fn excerpt(
text: &str,
phrase: &str,
options: ExcerptOptions,
) -> Option<String>
pub fn excerpt( text: &str, phrase: &str, options: ExcerptOptions, ) -> Option<String>
Extracts an excerpt from text that matches the first instance of a phrase
Sourcepub fn finish(value: &str, cap: &str) -> String
pub fn finish(value: &str, cap: &str) -> String
Cap a string with a single instance of a given value
Sourcepub fn wrap(value: &str, before: &str, after: Option<&str>) -> String
pub fn wrap(value: &str, before: &str, after: Option<&str>) -> String
Wrap the string with the given strings
Sourcepub fn unwrap(value: &str, before: &str, after: Option<&str>) -> String
pub fn unwrap(value: &str, before: &str, after: Option<&str>) -> String
Unwrap the string with the given strings
Sourcepub fn is_pattern(patterns: &[&str], value: &str, ignore_case: bool) -> bool
pub fn is_pattern(patterns: &[&str], value: &str, ignore_case: bool) -> bool
Determine if a given string matches a given pattern (with wildcards)
Sourcepub fn is_url(value: &str, protocols: Option<&[&str]>) -> bool
pub fn is_url(value: &str, protocols: Option<&[&str]>) -> bool
Determine if a given value is a valid URL
Sourcepub fn is_uuid(value: &str, version: Option<UuidVersion>) -> bool
pub fn is_uuid(value: &str, version: Option<UuidVersion>) -> bool
Determine if a given value is a valid UUID
Sourcepub fn limit(
value: &str,
limit: usize,
end: &str,
preserve_words: bool,
) -> String
pub fn limit( value: &str, limit: usize, end: &str, preserve_words: bool, ) -> String
Limit the number of characters in a string
Sourcepub fn words(value: &str, words: usize, end: &str) -> String
pub fn words(value: &str, words: usize, end: &str) -> String
Limit the number of words in a string
Sourcepub fn markdown(string: &str, options: MarkdownOptions) -> String
pub fn markdown(string: &str, options: MarkdownOptions) -> String
Converts GitHub flavored Markdown into HTML
Sourcepub fn inline_markdown(string: &str, options: MarkdownOptions) -> String
pub fn inline_markdown(string: &str, options: MarkdownOptions) -> String
Converts inline Markdown into HTML
Sourcepub fn mask(
string: &str,
character: char,
index: isize,
length: Option<usize>,
) -> String
pub fn mask( string: &str, character: char, index: isize, length: Option<usize>, ) -> String
Masks a portion of a string with a repeated character
Sourcepub fn match_pattern(pattern: &str, subject: &str) -> String
pub fn match_pattern(pattern: &str, subject: &str) -> String
Get the string matching the given pattern
Sourcepub fn is_match(patterns: &[&str], value: &str) -> bool
pub fn is_match(patterns: &[&str], value: &str) -> bool
Determine if a given string matches a given pattern
Sourcepub fn match_all(pattern: &str, subject: &str) -> Vec<String>
pub fn match_all(pattern: &str, subject: &str) -> Vec<String>
Get all strings matching the given pattern
Sourcepub fn pad_both(value: &str, length: usize, pad: &str) -> String
pub fn pad_both(value: &str, length: usize, pad: &str) -> String
Pad both sides of a string with another
Sourcepub fn pad_left(value: &str, length: usize, pad: &str) -> String
pub fn pad_left(value: &str, length: usize, pad: &str) -> String
Pad the left side of a string with another
Sourcepub fn pad_right(value: &str, length: usize, pad: &str) -> String
pub fn pad_right(value: &str, length: usize, pad: &str) -> String
Pad the right side of a string with another
Sourcepub fn parse_callback(
callback: &str,
default: Option<&str>,
) -> (String, Option<String>)
pub fn parse_callback( callback: &str, default: Option<&str>, ) -> (String, Option<String>)
Parse a Class[@]method style callback into class and method
Sourcepub fn plural(value: &str, count: i32, prepend_count: bool) -> String
pub fn plural(value: &str, count: i32, prepend_count: bool) -> String
Get the plural form of an English word
Sourcepub fn plural_studly(value: &str, count: i32) -> String
pub fn plural_studly(value: &str, count: i32) -> String
Pluralize the last word of an English, studly caps case string
Sourcepub fn plural_pascal(value: &str, count: i32) -> String
pub fn plural_pascal(value: &str, count: i32) -> String
Pluralize the last word of an English, Pascal caps case string
Sourcepub fn password(
length: usize,
letters: bool,
numbers: bool,
symbols: bool,
spaces: bool,
) -> String
pub fn password( length: usize, letters: bool, numbers: bool, symbols: bool, spaces: bool, ) -> String
Generate a random, secure password
Sourcepub fn position(haystack: &str, needle: &str, offset: usize) -> Option<usize>
pub fn position(haystack: &str, needle: &str, offset: usize) -> Option<usize>
Find the multi-byte safe position of the first occurrence of a given substring
Sourcepub fn create_random_strings_using<F>(factory: F)
pub fn create_random_strings_using<F>(factory: F)
Set the callable that will be used to generate random strings
Sourcepub fn create_random_strings_using_sequence(sequence: Vec<String>)
pub fn create_random_strings_using_sequence(sequence: Vec<String>)
Set the sequence that will be used to generate random strings
Sourcepub fn create_random_strings_normally()
pub fn create_random_strings_normally()
Indicate that random strings should be created normally
Sourcepub fn replace_array(search: &str, replace: &[&str], subject: &str) -> String
pub fn replace_array(search: &str, replace: &[&str], subject: &str) -> String
Replace a given value in the string sequentially with an array
Sourcepub fn replace(
search: &[&str],
replace: &[&str],
subject: &str,
case_sensitive: bool,
) -> String
pub fn replace( search: &[&str], replace: &[&str], subject: &str, case_sensitive: bool, ) -> String
Replace the given value in the given string
Sourcepub fn replace_first(search: &str, replace: &str, subject: &str) -> String
pub fn replace_first(search: &str, replace: &str, subject: &str) -> String
Replace the first occurrence of a given value in the string
Sourcepub fn replace_start(search: &str, replace: &str, subject: &str) -> String
pub fn replace_start(search: &str, replace: &str, subject: &str) -> String
Replace the first occurrence of the given value if it appears at the start
Sourcepub fn replace_last(search: &str, replace: &str, subject: &str) -> String
pub fn replace_last(search: &str, replace: &str, subject: &str) -> String
Replace the last occurrence of a given value in the string
Sourcepub fn replace_end(search: &str, replace: &str, subject: &str) -> String
pub fn replace_end(search: &str, replace: &str, subject: &str) -> String
Replace the last occurrence of a given value if it appears at the end
Sourcepub fn replace_matches(
pattern: &str,
replace: &str,
subject: &str,
limit: Option<usize>,
) -> String
pub fn replace_matches( pattern: &str, replace: &str, subject: &str, limit: Option<usize>, ) -> String
Replace the patterns matching the given regular expression
Sourcepub fn remove(search: &[&str], subject: &str, case_sensitive: bool) -> String
pub fn remove(search: &[&str], subject: &str, case_sensitive: bool) -> String
Remove any occurrence of the given string in the subject
Sourcepub fn start(value: &str, prefix: &str) -> String
pub fn start(value: &str, prefix: &str) -> String
Begin a string with a single instance of a given value
Sourcepub fn slug(
title: &str,
separator: &str,
language: Option<&str>,
dictionary: Option<HashMap<String, String>>,
) -> String
pub fn slug( title: &str, separator: &str, language: Option<&str>, dictionary: Option<HashMap<String, String>>, ) -> String
Generate a URL friendly “slug” from a given string
Sourcepub fn trim_custom(value: &str, charlist: Option<&str>) -> String
pub fn trim_custom(value: &str, charlist: Option<&str>) -> String
Remove all whitespace from both ends of a string with custom character list
Sourcepub fn ltrim(value: &str, charlist: Option<&str>) -> String
pub fn ltrim(value: &str, charlist: Option<&str>) -> String
Remove all whitespace from the beginning of a string
Sourcepub fn rtrim(value: &str, charlist: Option<&str>) -> String
pub fn rtrim(value: &str, charlist: Option<&str>) -> String
Remove all whitespace from the end of a string
Sourcepub fn starts_with(haystack: &str, needles: &[&str]) -> bool
pub fn starts_with(haystack: &str, needles: &[&str]) -> bool
Determine if a given string starts with a given substring
Sourcepub fn doesnt_start_with(haystack: &str, needles: &[&str]) -> bool
pub fn doesnt_start_with(haystack: &str, needles: &[&str]) -> bool
Determine if a given string doesn’t start with a given substring
Sourcepub fn substr(string: &str, start: isize, length: Option<usize>) -> String
pub fn substr(string: &str, start: isize, length: Option<usize>) -> String
Returns the portion of the string specified by the start and length parameters
Sourcepub fn substr_count(
haystack: &str,
needle: &str,
offset: usize,
length: Option<usize>,
) -> usize
pub fn substr_count( haystack: &str, needle: &str, offset: usize, length: Option<usize>, ) -> usize
Returns the number of substring occurrences
Sourcepub fn substr_replace(
string: &str,
replace: &str,
offset: isize,
length: Option<usize>,
) -> String
pub fn substr_replace( string: &str, replace: &str, offset: isize, length: Option<usize>, ) -> String
Replace text within a portion of a string
Sourcepub fn swap(map: HashMap<String, String>, subject: &str) -> String
pub fn swap(map: HashMap<String, String>, subject: &str) -> String
Swap multiple keywords in a string with other keywords
Sourcepub fn take(string: &str, limit: isize) -> String
pub fn take(string: &str, limit: isize) -> String
Take the first or last {$limit} characters of a string
Sourcepub fn from_base64(string: &str, strict: bool) -> Result<String, DecodeError>
pub fn from_base64(string: &str, strict: bool) -> Result<String, DecodeError>
Decode the given Base64 encoded string
Sourcepub fn uc_split(string: &str) -> Vec<String>
pub fn uc_split(string: &str) -> Vec<String>
Split a string into pieces by uppercase characters
Sourcepub fn word_count(string: &str, characters: Option<&str>) -> usize
pub fn word_count(string: &str, characters: Option<&str>) -> usize
Get the number of words a string contains
Sourcepub fn word_wrap(
string: &str,
characters: usize,
break_str: &str,
cut_long_words: bool,
) -> String
pub fn word_wrap( string: &str, characters: usize, break_str: &str, cut_long_words: bool, ) -> String
Wrap a string to a given number of characters
Sourcepub fn ordered_uuid() -> Uuid
pub fn ordered_uuid() -> Uuid
Generate a time-ordered UUID
Sourcepub fn create_uuids_using<F>(factory: F)
pub fn create_uuids_using<F>(factory: F)
Set the callable that will be used to generate UUIDs
Sourcepub fn create_uuids_using_sequence(sequence: Vec<Uuid>)
pub fn create_uuids_using_sequence(sequence: Vec<Uuid>)
Set the sequence that will be used to generate UUIDs
Sourcepub fn freeze_uuids<F>(callback: Option<F>) -> Uuid
pub fn freeze_uuids<F>(callback: Option<F>) -> Uuid
Always return the same UUID when generating new UUIDs
Sourcepub fn create_uuids_normally()
pub fn create_uuids_normally()
Indicate that UUIDs should be created normally and not using a custom factory
Sourcepub fn create_ulids_normally()
pub fn create_ulids_normally()
Indicate that ULIDs should be created normally and not using a custom factory
Sourcepub fn create_ulids_using<F>(factory: F)
pub fn create_ulids_using<F>(factory: F)
Set the callable that will be used to generate ULIDs
Sourcepub fn create_ulids_using_sequence(sequence: Vec<Ulid>)
pub fn create_ulids_using_sequence(sequence: Vec<Ulid>)
Set the sequence that will be used to generate ULIDs
Sourcepub fn freeze_ulids<F>(callback: Option<F>) -> Ulid
pub fn freeze_ulids<F>(callback: Option<F>) -> Ulid
Always return the same ULID when generating new ULIDs
Sourcepub fn flush_cache()
pub fn flush_cache()
Remove all strings from the casing caches