• Home
  • Raw
  • Download

Lines Matching full:regex

1 //! Module containing regex parsers on streams returning ranges of `&str` or `&[u8]`.
3 //! All regex parsers are overloaded on `&str` and `&[u8]` ranges and can take a `Regex` by value
6 //! Enabled using the `regex` feature (for `regex-0.2`) or the `regex-1` feature for `regex-1.0`.
10 //! use regex::{bytes, Regex};
12 //! use combine::parser::regex::{find_many, match_};
15 //! let regex = bytes::Regex::new("[0-9]+").unwrap();
16 //! // Shared references to any regex works as well
18 //! find_many(&regex).parse(&b"123 456 "[..]),
22 //! find_many(regex).parse(&b""[..]),
26 //! static REGEX: Lazy<Regex> = Lazy::new(|| Regex::new("[:alpha:]+").unwrap());
28 //! match_(&*REGEX).parse("abc123"),
64 pub trait Regex<Range> { trait
76 impl<'a, R, Range> Regex<Range> for &'a R impl
78 R: Regex<Range>,
118 #[cfg(feature = "regex")]
119 mod regex { module
120 pub extern crate regex;
124 use super::{find_iter, MatchFind, Regex};
126 pub use self::regex::*;
128 impl<'t> MatchFind for regex::Match<'t> {
131 regex::Match::end(self) in end()
138 impl<'t> MatchFind for regex::bytes::Match<'t> {
141 regex::bytes::Match::end(self) in end()
148 impl<'a> Regex<&'a str> for regex::Regex { implementation
150 regex::Regex::is_match(self, range) in is_match()
156 find_iter(regex::Regex::find_iter(self, range)) in find_iter()
164 let value = regex::Regex::captures_iter(self, range) in captures()
167 // The first group is the match on the entire regex in captures()
180 regex::Regex::as_str(self) in as_str()
184 impl<'a> Regex<&'a [u8]> for regex::bytes::Regex { implementation
186 regex::bytes::Regex::is_match(self, range) in is_match()
192 find_iter(regex::bytes::Regex::find_iter(self, range)) in find_iter()
200 let value = regex::bytes::Regex::captures_iter(self, range) in captures()
203 // The first group is the match on the entire regex in captures()
216 regex::bytes::Regex::as_str(self) in as_str()
225 R: Regex<Input::Range>,
250 /// Matches `regex` on the input returning the entire input if it matches.
254 /// extern crate regex;
256 /// use regex::Regex;
258 /// use combine::parser::regex::match_;
261 /// let regex = Regex::new("[:alpha:]+").unwrap();
263 /// match_(&regex).parse("abc123"),
268 pub fn match_<R, Input>(regex: R) -> Match<R, Input> in match_()
270 R: Regex<Input::Range>, in match_()
273 Match(regex, PhantomData) in match_()
281 R: Regex<Input::Range>,
307 /// Matches `regex` on the input by running `find` on the input and returns the first match.
311 /// extern crate regex;
313 /// use regex::Regex;
315 /// use combine::parser::regex::find;
318 /// let mut digits = find(Regex::new("^[0-9]+").unwrap());
323 /// let mut digits2 = find(Regex::new("[0-9]+").unwrap());
328 pub fn find<R, Input>(regex: R) -> Find<R, Input> in find()
330 R: Regex<Input::Range>, in find()
334 Find(regex, PhantomData) in find()
343 R: Regex<Input::Range>,
366 /// Matches `regex` on the input by running `find_iter` on the input.
371 /// extern crate regex;
373 /// use regex::Regex;
374 /// use regex::bytes;
376 /// use combine::parser::regex::find_many;
379 /// let mut digits = find_many(Regex::new("[0-9]+").unwrap());
385 pub fn find_many<F, R, Input>(regex: R) -> FindMany<F, R, Input> in find_many()
388 R: Regex<Input::Range>, in find_many()
392 FindMany(regex, PhantomData) in find_many()
401 R: Regex<Input::Range>,
427 /// Matches `regex` on the input by running `captures_iter` on the input.
431 /// extern crate regex;
433 /// use regex::Regex;
435 /// use combine::parser::regex::captures;
438 /// let mut fields = captures(Regex::new("([a-z]+):([0-9]+)").unwrap());
453 pub fn captures<F, R, Input>(regex: R) -> Captures<F, R, Input> in captures()
456 R: Regex<Input::Range>, in captures()
460 Captures(regex, PhantomData) in captures()
470 R: Regex<Input::Range>,
493 /// Matches `regex` on the input by running `captures_iter` on the input.
498 /// extern crate regex;
500 /// use regex::Regex;
502 /// use combine::parser::regex::captures_many;
505 /// let mut fields = captures_many(Regex::new("([a-z]+):([0-9]+)").unwrap());
521 pub fn captures_many<F, G, R, Input>(regex: R) -> CapturesMany<F, G, R, Input> in captures_many()
525 R: Regex<Input::Range>, in captures_many()
529 CapturesMany(regex, PhantomData) in captures_many()
535 use regex::Regex;
537 use crate::{parser::regex::find, Parser};
541 let mut digits = find(Regex::new("^[0-9]+").unwrap()); in test()
545 let mut digits2 = find(Regex::new("[0-9]+").unwrap()); in test()