Skip to main content

StripCharacters

Trait StripCharacters 

Source
pub trait StripCharacters<'a>
where Self: ToSegments,
{
Show 18 methods // Required methods fn alphanumeric_chars(&self) -> impl DoubleEndedIterator<Item = char> + '_; fn strip_non_alphanum(&self) -> String; fn strip_non_digits(&self) -> String; fn strip_by_type(&self, ct: CharType<'a>) -> String; fn strip_by_types(&self, cts: &[CharType<'a>]) -> String; fn filter_by_type(&self, ct: CharType<'a>) -> String; fn filter_by_types(&self, cts: &[CharType<'a>]) -> String; fn to_numeric_strings_strict( &self, separator: DecimalSeparator, ) -> Vec<String>; fn to_numbers_strict<N: FromStr>( &self, separator: DecimalSeparator, ) -> Vec<N>; fn split_to_numbers<N: FromStr + Copy>(&self, pattern: &str) -> Vec<N>; fn correct_numeric_string_strict( &self, separator: DecimalSeparator, ) -> String; // Provided methods fn strip_spaces(&self) -> String { ... } fn to_numeric_strings(&self) -> Vec<String> { ... } fn to_numbers<N: FromStr>(&self) -> Vec<N> { ... } fn correct_numeric_string(&self) -> String { ... } fn to_first_number<N: FromStr + Copy>(&self) -> Option<N> { ... } fn to_first_number_strict<N: FromStr + Copy>( &self, separator: DecimalSeparator, ) -> Option<N> { ... } fn strip_non_numeric(&self) -> String { ... }
}
Expand description

Set of methods to strip unwanted characters by type or extract vectors of numeric strings, integers or floats

Required Methods§

Source

fn alphanumeric_chars(&self) -> impl DoubleEndedIterator<Item = char> + '_

Lazily iterates the alphanumeric characters only, without allocating a String. strip_non_alphanum is built on this; prefer this directly if you only need to scan or compare the filtered characters rather than build an owned copy. Double-ended, so callers needing to scan from the end can call .rev() on it.

Source

fn strip_non_alphanum(&self) -> String

Remove all non-alphanumeric characters

Source

fn strip_non_digits(&self) -> String

Remove all non-digit characters

Source

fn strip_by_type(&self, ct: CharType<'a>) -> String

Remove characters matching a specific type

Source

fn strip_by_types(&self, cts: &[CharType<'a>]) -> String

Remove characters matching any of the specified types

Source

fn filter_by_type(&self, ct: CharType<'a>) -> String

Keep only characters matching a specific type

Source

fn filter_by_types(&self, cts: &[CharType<'a>]) -> String

Keep only characters matching any of the specified types

Source

fn to_numeric_strings_strict(&self, separator: DecimalSeparator) -> Vec<String>

Extract numeric strings with configurable decimal separator

Source

fn to_numbers_strict<N: FromStr>(&self, separator: DecimalSeparator) -> Vec<N>

Parse extracted numbers with configurable decimal separator

Source

fn split_to_numbers<N: FromStr + Copy>(&self, pattern: &str) -> Vec<N>

Split by pattern and extract the first number from each segment

Source

fn correct_numeric_string_strict(&self, separator: DecimalSeparator) -> String

Normalize numeric string separators based on decimal separator convention

Provided Methods§

Source

fn strip_spaces(&self) -> String

Remove whitespace characters

Source

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

Extract numeric strings using auto-detection

Source

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

Parse numbers using auto-detection

Source

fn correct_numeric_string(&self) -> String

Normalize numeric string separators using auto-detection

Source

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

Extract the first parsed number using auto-detection, or None if empty

Source

fn to_first_number_strict<N: FromStr + Copy>( &self, separator: DecimalSeparator, ) -> Option<N>

Extract the first parsed number with configurable decimal separator, or None if empty

Source

fn strip_non_numeric(&self) -> String

Extract numeric strings and join them with spaces

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, T: AsRef<str>> StripCharacters<'a> for T