• Home
  • Raw
  • Download

Lines Matching full:regex

13 documentation for the [`Regex`](struct.Regex.html) type.
17 This crate is [on crates.io](https://crates.io/crates/regex) and can be
18 used by adding `regex` to your dependencies in your project's `Cargo.toml`.
22 regex = "1"
32 use regex::Regex;
33 let re = Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
49 # Example: Avoid compiling the same regex in a loop
54 regex.) Not only is compilation itself expensive, but this also prevents
66 use regex::Regex;
70 static ref RE: Regex = Regex::new("...").unwrap();
78 Specifically, in this example, the regex will be compiled when it is used for
89 # use regex::Regex;
91 let re = Regex::new(r"(\d{4})-(\d{2})-(\d{2})").unwrap();
114 # use regex::Regex;
116 let re = Regex::new(r"(?P<y>\d{4})-(?P<m>\d{2})-(?P<d>\d{2})").unwrap();
125 `Regex::replace` for more details.)
127 Note that if your regex gets complicated, you can use the `x` flag to
131 # use regex::Regex;
133 let re = Regex::new(r"(?x)
157 use regex::RegexSet;
173 // You can also test whether a particular regex matched:
212 # use regex::Regex;
214 let re = Regex::new(r"(?i)Δ+").unwrap();
239 # use regex::Regex;
241 let re = Regex::new(r"[\pN\p{Greek}\p{Cherokee}]+").unwrap();
250 [UNICODE](https://github.com/rust-lang/regex/blob/master/UNICODE.md)
251 document in the root of the regex repository.
255 The `bytes` sub-module provides a `Regex` type that can be used to match
257 the main `Regex` type. However, this behavior can be disabled by turning
262 Disabling the `u` flag is also possible with the standard `&str`-based `Regex`
265 `&str`-based `Regex`, but `(?-u:\xFF)` will attempt to match the raw byte
280 a separate crate, [`regex-syntax`](https://docs.rs/regex-syntax).
356 The empty regex is valid and matches the empty string. For example, the empty
357 regex matches `abc` at positions `0`, `1`, `2` and `3`.
389 # use regex::Regex;
391 let re = Regex::new(r"(?i)a+(?-i)b+").unwrap();
404 # use regex::Regex;
405 let re = Regex::new(r"(?m)^line \d+").unwrap();
413 # use regex::Regex;
414 let re = Regex::new(r"(?m)^").unwrap();
423 # use regex::Regex;
425 let re = Regex::new(r"(?-u:\b).+(?-u:\b)").unwrap();
485 By default, this crate tries pretty hard to make regex matching both as fast
491 is still left with a perfectly serviceable regex engine that will work well
499 `unicode-case` feature (described below), then compiling the regex `(?i)a`
511 When enabled, this will cause `regex` to use the standard library. Currently,
513 intended to add `alloc`-only support to regex in the future.
523 portions of a regex to a very fast DFA on an as-needed basis. This can
593 crate have time complexity `O(mn)` (with `m ~ regex` and `n ~ search
620 // See: https://github.com/rust-lang/regex/issues/684
621 // See: https://github.com/rust-lang/regex/issues/685
636 Locations, Match, Matches, NoExpand, Regex, Replacer, ReplacerRef, Split,
656 # use regex::bytes::Regex;
657 let re = Regex::new(r"(?-u)(?P<cstr>[^\x00]+)\x00").unwrap();
676 # use regex::bytes::Regex;
677 let re = Regex::new(
704 1. The `u` flag can be disabled even when disabling it might cause the regex to
705 match invalid UTF-8. When the `u` flag is disabled, the regex is said to be in
759 /// testing different matching engines and supporting the `regex-debug` CLI