// Copyright (c) 2018 The predicates-rs Project Developers. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
/// An error that occurred during parsing or compiling a regular expression. pubtype RegexError = regex::Error;
/// Predicate that uses regex matching /// /// This is created by the `predicate::str::is_match`. #[derive(Debug, Clone)] pubstruct RegexPredicate {
re: regex::Regex,
}
impl RegexPredicate { /// Require a specific count of matches. /// /// # Examples /// /// ``` /// use predicates::prelude::*; /// /// let predicate_fn = predicate::str::is_match("T[a-z]*").unwrap().count(3); /// assert_eq!(true, predicate_fn.eval("One Two Three Two One")); /// assert_eq!(false, predicate_fn.eval("One Two Three")); /// ``` pubfn count(self, count: usize) -> RegexMatchesPredicate {
RegexMatchesPredicate { re: self.re, count }
}
}
/// Predicate that checks for repeated patterns. /// /// This is created by `predicates::str::is_match(...).count`. #[derive(Debug, Clone)] pubstruct RegexMatchesPredicate {
re: regex::Regex,
count: usize,
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.