pub fn extract_numbers(entry: &str, reg: &str) -> Result<Vec<String>, BibiError> {
        let mut numbers: Vec<String> = vec![];

        if !reg.is_empty() {
            let re: Regex = match Regex::new(&reg[..]) {
                Ok(res) => res,
                Err(_) => return Err(BibiError::BadRegularExpression),
            };
            let caps = match re.captures(entry) {
                Some(caps) => caps,
                None => return Err(BibiError::RegexMismatchWithEntry),
            };
            for number in caps.iter().skip(1) {
                if let Some(numberok) = number {
                    numbers.push(numberok.as_str().to_string());
                }
            }
        } else {
            numbers.push(entry.to_string());
        }

        Ok(numbers)
    }
/// find all numbers in entry from regular expression
find all numbers in entry from regular expression
find all numbers in entry from regular expression
pub fn extract_numbers(entry: &str, reg: &str) -> Result<Vec<String>, BibiError> {
        let mut numbers: Vec<String> = vec![];
        if !reg.is_empty() {
            let re: Regex = match Regex::new(&reg[..]) {
                Ok(res) => res,
                Err(_) => return Err(BibiError::BadRegularExpression),
            };
            let caps = match re.captures(entry) {
                Some(caps) => caps,
                None => return Err(BibiError::RegexMismatchWithEntry),
            };
            for number in caps.iter().skip(1) {
                if let Some(numberok) = number {
                    numbers.push(numberok.as_str().to_string());
                }
            }
        } else {
            numbers.push(entry.to_string());
        }
        Ok(numbers)
    }
pub fn extract_numbers ( entry : & str , reg : & str ) -> Result < Vec < String > , BibiError > { let mut numbers : Vec < String > = vec ! [ ] ; if ! reg . is_empty ( ) { let re : Regex = match Regex :: new ( & reg [ .. ] ) { Ok ( res ) => res , Err ( _ ) => return Err ( BibiError :: BadRegularExpression ) , } ; let caps = match re . captures ( entry ) { Some ( caps ) => caps , None => return Err ( BibiError :: RegexMismatchWithEntry ) , } ; for number in caps . iter ( ) . skip ( 1 ) { if let Some ( numberok ) = number { numbers . push ( numberok . as_str ( ) . to_string ( ) ) ; } } } else { numbers . push ( entry . to_string ( ) ) ; } Ok ( numbers ) }
find all numbers in entry from regular expression
find all numbers in entry from regular expression
entry
&str
reg
&str
entry
&str
reg
&str