[−][src]Module combine::parser::regex
regex
only.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 (&
).
Enabled using the regex
feature (for regex-0.2
) or the regex-1
feature for regex-1.0
.
use once_cell::sync::Lazy; 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""[..])) ); static REGEX: Lazy<Regex> = Lazy::new(|| 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 |