Cargo Features
[dependencies]
regex = { version = "1.11.0", default-features = false, features = ["std", "logging", "use_std", "perf", "perf-dfa", "perf-dfa-full", "perf-onepass", "perf-backtrack", "perf-inline", "perf-literal", "perf-cache", "unicode", "unicode-age", "unicode-bool", "unicode-case", "unicode-gencat", "unicode-perl", "unicode-script", "unicode-segment", "unstable", "pattern"] }
Features are documented in the "Crate features" section of the crate docs: https://docs.rs/regex/*/#crate-features
- default = perf, std, unicode
-
These default features are set whenever
regex
is added without
somewhere in the dependency tree.default-features = false Enables regex-syntax
- std default use_std?
-
ECOSYSTEM FEATURES
The 'std' feature permits the regex crate to use the standard library. This is intended to support future use cases where the regex crate may be able to compile without std, and instead just rely on 'core' and 'alloc' (for example). Currently, this isn't supported, and removing the 'std' feature will prevent regex from compiling.Enables std of optional aho-corasick, optional memchr, regex-automata, and regex-syntax
- logging
-
This feature enables the 'log' crate to emit messages. This is usually only useful for folks working on the regex crate itself, but can be useful if you're trying hard to do some performance hacking on regex patterns themselves. Note that you'll need to pair this with a crate like 'env_logger'
to actually emit the log messages somewhere.Enables logging of optional aho-corasick, optional memchr, and regex-automata
- use_std = std
-
The 'use_std' feature is DEPRECATED. It will be removed in regex 2. Until then, it is an alias for the 'std' feature.
- perf default = perf-backtrack, perf-cache, perf-dfa, perf-inline, perf-literal, perf-onepass
-
PERFORMANCE FEATURES
Enables all default performance features. Note that this specifically does not include perf-dfa-full, because it leads to higher compile times and bigger binaries, and the runtime performance improvement is not obviously worth it. - perf-dfa perf
-
Enables use of a lazy DFA when possible.
Enables hybrid of regex-automata
- perf-dfa-full
-
Enables use of a fully compiled DFA when possible.
Enables dfa-build and dfa-search of regex-automata
- perf-onepass perf
-
Enables use of the one-pass regex matcher, which speeds up capture searches even beyond the backtracker.
Enables dfa-onepass of regex-automata
- perf-backtrack perf
-
Enables use of a bounded backtracker, which speeds up capture searches.
Enables nfa-backtrack of regex-automata
- perf-inline perf
-
Enables aggressive use of inlining.
Enables perf-inline of regex-automata
- perf-literal perf
-
Enables literal optimizations.
Enables aho-corasick and memchr, perf-literal of regex-automata
- perf-cache perf
-
Enables fast caching. (If disabled, caching is still used, but is slower.)
Currently, this feature has no effect. It used to remove the thread_local dependency and use a slower internal cache, but now the default cache has been improved and thread_local is no longer a dependency at all. - unicode default = unicode-age, unicode-bool, unicode-case, unicode-gencat, unicode-perl, unicode-script, unicode-segment
-
UNICODE DATA FEATURES
Enables all Unicode features. This expands if new Unicode features are added.Enables unicode of regex-automata and regex-syntax
- unicode-age unicode
-
Enables use of the
Age
property, e.g.,\p{Age:3.0}
.Enables unicode-age of regex-automata and regex-syntax
- unicode-bool unicode
-
Enables use of a smattering of boolean properties, e.g.,
\p{Emoji}
.Enables unicode-bool of regex-automata and regex-syntax
- unicode-case unicode
-
Enables Unicode-aware case insensitive matching, e.g.,
(?i)β
.Enables unicode-case of regex-automata and regex-syntax
- unicode-gencat unicode
-
Enables Unicode general categories, e.g.,
\p{Letter}
or\pL
.Enables unicode-gencat of regex-automata and regex-syntax
- unicode-perl unicode
-
Enables Unicode-aware Perl classes corresponding to
\w
,\s
and\d
.Enables unicode-perl and unicode-word-boundary of regex-automata, unicode-perl of regex-syntax
- unicode-script unicode
-
Enables Unicode scripts and script extensions, e.g.,
\p{Greek}
.Enables unicode-script of regex-automata and regex-syntax
- unicode-segment unicode
-
Enables Unicode segmentation properties, e.g.,
\p{gcb=Extend}
.Enables unicode-segment of regex-automata and regex-syntax
- unstable = pattern
-
UNSTABLE FEATURES (requires Rust nightly)
A blanket feature that governs whether unstable features are enabled or not.
Unstable features are disabled by default, and typically rely on unstable features in rustc itself. - pattern unstable?
-
Enable to use the unstable pattern traits defined in std. This is enabled by default if the unstable feature is enabled.