Crate rexify

Crate rexify 

Source
Expand description

This crate provide routines for trait based searching and captureing strings for matches instead of regex crate. This is developed as an alternative of regex crate.

§Overview

The primary type in this crate is a Rex, and trait is Matcher.

Rex implements Matcher trait.

Matcher has two methods as follows:

  • Matcher::match_with : reports whether a match matches with target and the length
  • Matcher::capture: returns matched length and captured str slice.
  • Matcher::find: find matches and returns the offset.

§Example

use rexify::Rex;
use rexify::Matcher;
use rexify::number::Number;
use rexify::any_char::AnyChar;
use rexify::repeats::Repeat1;

let rex = Rex::new(vec![
    Box::new(Number::new()),
    Box::new(Repeat1::new(AnyChar::new())),
]);
let text = "asdija123102abc";

assert_eq!(rex.find(text), Some(6));
assert_eq!(rex.capture(&text[6 ..]), Some((9, vec!["123102", "a", "b", "c"])));

Re-exports§

pub use alpha::*;
pub use any_char::*;
pub use literal::*;
pub use number::*;
pub use range::*;
pub use repeats::*;
pub use select::*;

Modules§

alpha
This module provides alphabet matcher.
any_char
This module provides any char matcher like “.” in regex.
literal
This module provides string literal matcher.
number
This module provides number matcher.
range
This module provides range matcher.
repeats
This module provides some repeat matchers.
select
This module provides selector matcher.

Structs§

Rex
Search matches in a haystack. This is same to Regex type.

Traits§

Matcher
A trait for types that is used to match in a haystack.