• Home
  • Raw
  • Download

Lines Matching +full:regex +full:- +full:not

11 * A [`Regex`](struct.Regex.html) provides a way to search for matches of a
15 compilation options for a regex.
27 # Example: basic regex searching
29 This example shows how to compile a regex using the default configuration
33 use regex_automata::Regex;
35 let re = Regex::new(r"[0-9]{4}-[0-9]{2}-[0-9]{2}").unwrap();
36 let text = b"2018-12-24 2016-10-08";
43 By default, compiling a regex will use dense DFAs internally. This uses more
45 (somewhere around 3-5x), then sparse DFAs might make more sense since they can
48 Using sparse DFAs is as easy as using `Regex::new_sparse` instead of
49 `Regex::new`:
52 use regex_automata::Regex;
54 # fn example() -> Result<(), regex_automata::Error> {
55 let re = Regex::new_sparse(r"[0-9]{4}-[0-9]{2}-[0-9]{2}").unwrap();
56 let text = b"2018-12-24 2016-10-08";
63 DFAs and used to build a new `Regex`. For example:
66 use regex_automata::Regex;
68 # fn example() -> Result<(), regex_automata::Error> {
69 let dense_re = Regex::new(r"[0-9]{4}-[0-9]{2}-[0-9]{2}").unwrap();
70 let sparse_re = Regex::from_dfas(
74 let text = b"2018-12-24 2016-10-08";
90 use regex_automata::{DenseDFA, Regex};
92 # fn example() -> Result<(), regex_automata::Error> {
93 let re1 = Regex::new(r"[0-9]{4}-[0-9]{2}-[0-9]{2}").unwrap();
97 // now deserialize both---we need to specify the correct type!
100 // finally, reconstruct our regex
101 let re2 = Regex::from_dfas(fwd, rev);
104 let text = b"2018-12-24 2016-10-08";
112 * We need to extract the raw DFAs used by the regex and serialize those. You
115 `Regex` guarantees that the DFAs are built correctly.
120 use `usize` for state identifiers, which does not have a fixed size. Using
143 use regex_automata::{SparseDFA, Regex};
145 # fn example() -> Result<(), regex_automata::Error> {
146 let re1 = Regex::new(r"[0-9]{4}-[0-9]{2}-[0-9]{2}").unwrap();
150 // now deserialize both---we need to specify the correct type!
153 // finally, reconstruct our regex
154 let re2 = Regex::from_dfas(fwd, rev);
157 let text = b"2018-12-24 2016-10-08";
182 DFA. (So that's 4 DFAs in total for each regex.)
185 as you would any regex.
191 [`ucd-generate`](https://github.com/BurntSushi/ucd-generate)
192 tool will do the first step for you with its `dfa` or `regex` sub-commands.
196 This crate supports the same syntax as the `regex` crate, since they share the
198 [documentation for the `regex` crate](https://docs.rs/regex/1.1/regex/#syntax).
200 Currently, there are a couple limitations. In general, this crate does not
201 support zero-width assertions, although they may be added in the future. This
210 option when building a regex. By default, all searches are unanchored.
212 # Differences with the regex crate
214 The main goal of the [`regex`](https://docs.rs/regex) crate is to serve as a
224 of the regex pattern. While most patterns do not exhibit worst case
227 not be compiled with this library. (In the future, the API may expose an
229 * This crate does not support sub-match extraction, which can be achieved with
230 the regex crate's "captures" API. This may be added in the future, but is
232 * While the regex crate doesn't necessarily sport fast compilation times, the
236 almost 5MB of memory! (Compiling a sparse regex takes about the same time
237 but only uses about 500KB of memory.) Conversly, compiling the same regex
238 without Unicode support, e.g., `(?-u)\w{3}`, takes under 1 millisecond and
241 * This crate does not support regex sets.
242 * This crate does not support zero-width assertions such as `^`, `$`, `\b` or
244 * As a lower level crate, this library does not do literal optimizations. In
248 * There is no `&str` API like in the regex crate. In this crate, all APIs
250 UTF-8 boundaries, unless
262 deserialize pre-compiled regexes.
263 * Since this crate builds DFAs ahead of time, it will generally out-perform
264 the `regex` crate on equivalent tasks. The performance difference is likely
265 not large. However, because of a complex set of optimizations in the regex
270 even less than what the regex crate uses.
274 need the end of a match and not the start of a match, then you can use a DFA
275 directly without building a `Regex`, which always requires a second DFA to
286 #![cfg_attr(not(feature = "std"), no_std)]
302 pub use regex::Regex;
304 pub use regex::RegexBuilder;
322 mod regex; module
350 /// Unlike the [`dense`](../dense/index.html) module, this module does not