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§

source

fn strip_non_chars(&self) -> Self
where 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

source

fn strip_non_digits(&self) -> Self
where Self: Sized,

source

fn to_numeric_strings(&self) -> Vec<String>

Extracts valid numeric string components from a longer string

source

fn to_numeric_strings_euro(&self) -> Vec<String>

Always interpret numeric strings with dots as thousand separators and commas as decimal separators

source

fn to_numeric_strings_conditional( &self, enforce_comma_separator: bool ) -> Vec<String>

source

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.

source

fn to_numbers<T: FromStr>(&self) -> Vec<T>

Extracts valid integers or floats from a longer string

source

fn to_numbers_euro<T: FromStr>(&self) -> Vec<T>

source

fn correct_numeric_string(&self, enforce_comma_separator: bool) -> Self

Correct number

source

fn to_first_number<T: FromStr + Copy>(&self) -> Option<T>

Extracts the first valid integer or float from a longer string if present

source

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

source

fn strip_non_numeric(&self) -> Self
where Self: Sized,

Removes all characters no used in valid numeric sequences

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl StripCharacters for String

source§

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>

conditionally extract numeric strings from a longer string

source§

fn strip_non_chars(&self) -> String

source§

fn strip_non_digits(&self) -> String

source§

fn to_numeric_strings(&self) -> Vec<String>

source§

fn to_numeric_strings_euro(&self) -> Vec<String>

source§

fn to_numbers_conditional<T: FromStr>( &self, enforce_comma_separator: bool ) -> Vec<T>

source§

fn to_numbers<T: FromStr>(&self) -> Vec<T>

source§

fn to_numbers_euro<T: FromStr>(&self) -> Vec<T>

source§

fn to_first_number<T: FromStr + Copy>(&self) -> Option<T>

source§

fn to_first_number_euro<T: FromStr + Copy>(&self) -> Option<T>

source§

fn strip_non_numeric(&self) -> String

Implementors§