Module combine::parser::regex
[−]
[src]
Module containing regex parsers on streams returning ranges of &str
or &[u8]
.
All regex parsers are overloaded on &str
and &[u8]
ranges and can take a Regex
by value
or shared reference (&
)
extern crate regex; #[macro_use] extern crate lazy_static; extern crate combine; use regex::{bytes, Regex}; use combine::Parser; use combine::parser::regex::{find_many, match_}; fn main() { let regex = bytes::Regex::new("[0-9]+").unwrap(); // Shared references to any regex works as well assert_eq!( find_many(®ex).parse(&b"123 456 "[..]), Ok((vec![&b"123"[..], &b"456"[..]], &b" "[..])) ); assert_eq!( find_many(regex).parse(&b""[..]), Ok((vec![], &b""[..])) ); lazy_static! { static ref REGEX: Regex = Regex::new("[:alpha:]+").unwrap(); } assert_eq!( match_(&*REGEX).parse("abc123"), Ok(("abc123", "abc123")) ); }
Structs
Captures | |
CapturesMany | |
Find | |
FindMany | |
Match |
Traits
MatchFind | |
Regex |
Functions
captures |
Matches |
captures_many |
Matches |
find |
Matches |
find_many |
Matches |
match_ |
Matches |