Trait string_patterns::StripCharacters
source · pub trait StripCharacters {
// Required methods
fn strip_non_chars(&self) -> Self
where Self: Sized;
fn strip_non_digits(&self) -> Self
where Self: Sized;
fn to_numeric_strings(&self) -> Vec<String>;
fn to_numeric_strings_euro(&self) -> Vec<String>;
fn to_numeric_strings_conditional(
&self,
enforce_comma_separator: bool
) -> Vec<String>;
fn to_numbers_conditional<T: FromStr>(
&self,
enforce_comma_separator: bool
) -> Vec<T>;
fn to_numbers<T: FromStr>(&self) -> Vec<T>;
fn to_numbers_euro<T: FromStr>(&self) -> Vec<T>;
fn correct_numeric_string(&self, enforce_comma_separator: bool) -> Self;
fn to_first_number<T: FromStr + Copy>(&self) -> Option<T>;
fn to_first_number_euro<T: FromStr + Copy>(&self) -> Option<T>;
fn strip_non_numeric(&self) -> Self
where Self: Sized;
}
Required Methods§
sourcefn strip_non_chars(&self) -> Selfwhere
Self: Sized,
fn strip_non_chars(&self) -> Selfwhere
Self: Sized,
Removes all characters that any are not letters or digits, such as punctuation or symobols Letters include those used in most non-Latin alphabets
fn strip_non_digits(&self) -> Selfwhere
Self: Sized,
sourcefn to_numeric_strings(&self) -> Vec<String>
fn to_numeric_strings(&self) -> Vec<String>
Extracts valid numeric string components from a longer string
sourcefn to_numeric_strings_euro(&self) -> Vec<String>
fn to_numeric_strings_euro(&self) -> Vec<String>
Always interpret numeric strings with dots as thousand separators and commas as decimal separators
fn to_numeric_strings_conditional( &self, enforce_comma_separator: bool ) -> Vec<String>
sourcefn to_numbers_conditional<T: FromStr>(
&self,
enforce_comma_separator: bool
) -> Vec<T>
fn to_numbers_conditional<T: FromStr>( &self, enforce_comma_separator: bool ) -> Vec<T>
Extract numeric strings and cast to numbers with conditional logic over commas and dots, The boolean flag enforces European logic where dots separate thousands and commas decimals Otherwise the correct format is deduced. Numeric strings are problematic when they only contain one comma or point. Otherwise the last separator is always considered the decimal separator if it differs from the first separators.
sourcefn to_numbers<T: FromStr>(&self) -> Vec<T>
fn to_numbers<T: FromStr>(&self) -> Vec<T>
Extracts valid integers or floats from a longer string
fn to_numbers_euro<T: FromStr>(&self) -> Vec<T>
sourcefn correct_numeric_string(&self, enforce_comma_separator: bool) -> Self
fn correct_numeric_string(&self, enforce_comma_separator: bool) -> Self
Correct number
sourcefn to_first_number<T: FromStr + Copy>(&self) -> Option<T>
fn to_first_number<T: FromStr + Copy>(&self) -> Option<T>
Extracts the first valid integer or float from a longer string if present
sourcefn to_first_number_euro<T: FromStr + Copy>(&self) -> Option<T>
fn to_first_number_euro<T: FromStr + Copy>(&self) -> Option<T>
Extracts the first valid integer or float from a longer string if commas are used for decimals and dots for thousand separators
sourcefn strip_non_numeric(&self) -> Selfwhere
Self: Sized,
fn strip_non_numeric(&self) -> Selfwhere
Self: Sized,
Removes all characters no used in valid numeric sequences
Object Safety§
Implementations on Foreign Types§
source§impl StripCharacters for String
impl StripCharacters for String
source§fn correct_numeric_string(&self, enforce_comma_separator: bool) -> Self
fn correct_numeric_string(&self, enforce_comma_separator: bool) -> Self
Correct numeric strings with commas as thousand separators or as decimal separators to a regular format with punctuation only for decimal points before being parsed to an integer or float
source§fn to_numeric_strings_conditional(
&self,
enforce_comma_separator: bool
) -> Vec<String>
fn to_numeric_strings_conditional( &self, enforce_comma_separator: bool ) -> Vec<String>
conditionally extract numeric strings from a longer string