Struct pcre2::bytes::RegexBuilder [−][src]
pub struct RegexBuilder { /* fields omitted */ }
A builder for configuring the compilation of a PCRE2 regex.
Methods
impl RegexBuilder
[src]
impl RegexBuilder
pub fn new() -> RegexBuilder
[src]
pub fn new() -> RegexBuilder
Create a new builder with a default configuration.
pub fn build(&self, pattern: &str) -> Result<Regex, Error>
[src]
pub fn build(&self, pattern: &str) -> Result<Regex, Error>
Compile the given pattern into a PCRE regex using the current configuration.
If there was a problem compiling the pattern, then an error is returned.
pub fn caseless(&mut self, yes: bool) -> &mut RegexBuilder
[src]
pub fn caseless(&mut self, yes: bool) -> &mut RegexBuilder
Enables case insensitive matching.
If the utf
option is also set, then Unicode case folding is used
to determine case insensitivity. When the utf
option is not set,
then only standard ASCII case insensitivity is considered.
This option corresponds to the i
flag.
pub fn dotall(&mut self, yes: bool) -> &mut RegexBuilder
[src]
pub fn dotall(&mut self, yes: bool) -> &mut RegexBuilder
Enables "dot all" matching.
When enabled, the .
metacharacter in the pattern matches any
character, include \n
. When disabled (the default), .
will match
any character except for \n
.
This option corresponds to the s
flag.
pub fn extended(&mut self, yes: bool) -> &mut RegexBuilder
[src]
pub fn extended(&mut self, yes: bool) -> &mut RegexBuilder
Enable "extended" mode in the pattern, where whitespace is ignored.
This option corresponds to the x
flag.
pub fn multi_line(&mut self, yes: bool) -> &mut RegexBuilder
[src]
pub fn multi_line(&mut self, yes: bool) -> &mut RegexBuilder
Enable multiline matching mode.
When enabled, the ^
and $
anchors will match both at the beginning
and end of a subject string, in addition to matching at the start of
a line and the end of a line. When disabled, the ^
and $
anchors
will only match at the beginning and end of a subject string.
This option corresponds to the m
flag.
pub fn crlf(&mut self, yes: bool) -> &mut RegexBuilder
[src]
pub fn crlf(&mut self, yes: bool) -> &mut RegexBuilder
Enable matching of CRLF as a line terminator.
When enabled, anchors such as ^
and $
will match any of the
following as a line terminator: \r
, \n
or \r\n
.
This is disabled by default, in which case, only \n
is recognized as
a line terminator.
pub fn ucp(&mut self, yes: bool) -> &mut RegexBuilder
[src]
pub fn ucp(&mut self, yes: bool) -> &mut RegexBuilder
Enable Unicode matching mode.
When enabled, the following patterns become Unicode aware: \b
, \B
,
\d
, \D
, \s
, \S
, \w
, \W
.
When set, this implies UTF matching mode. It is not possible to enable Unicode matching mode without enabling UTF matching mode.
This is disabled by default.
pub fn utf(&mut self, yes: bool) -> &mut RegexBuilder
[src]
pub fn utf(&mut self, yes: bool) -> &mut RegexBuilder
Enable UTF matching mode.
When enabled, characters are treated as sequences of code units that
make up a single codepoint instead of as single bytes. For example,
this will cause .
to match any single UTF-8 encoded codepoint, where
as when this is disabled, .
will any single byte (except for \n
in
both cases, unless "dot all" mode is enabled).
Note that when UTF matching mode is enabled, every search performed
will do a UTF-8 validation check, which can impact performance. The
UTF-8 check can be disabled via the disable_utf_check
option, but it
is undefined behavior to enable UTF matching mode and search invalid
UTF-8.
This is disabled by default.
pub unsafe fn disable_utf_check(&mut self) -> &mut RegexBuilder
[src]
pub unsafe fn disable_utf_check(&mut self) -> &mut RegexBuilder
When UTF matching mode is enabled, this will disable the UTF checking that PCRE2 will normally perform automatically. If UTF matching mode is not enabled, then this has no effect.
UTF checking is enabled by default when UTF matching mode is enabled. If UTF matching mode is enabled and UTF checking is enabled, then PCRE2 will return an error if you attempt to search a subject string that is not valid UTF-8.
Safety
It is undefined behavior to disable the UTF check in UTF matching mode and search a subject string that is not valid UTF-8. When the UTF check is disabled, callers must guarantee that the subject string is valid UTF-8.
pub fn jit(&mut self, yes: bool) -> &mut RegexBuilder
[src]
pub fn jit(&mut self, yes: bool) -> &mut RegexBuilder
Enable PCRE2's JIT and return an error if it's not available.
This generally speeds up matching quite a bit. The downside is that it can increase the time it takes to compile a pattern.
If the JIT isn't available or if JIT compilation returns an error, then regex compilation will fail with the corresponding error.
This is disabled by default, and always overrides jit_if_available
.
pub fn jit_if_available(&mut self, yes: bool) -> &mut RegexBuilder
[src]
pub fn jit_if_available(&mut self, yes: bool) -> &mut RegexBuilder
Enable PCRE2's JIT if it's available.
This generally speeds up matching quite a bit. The downside is that it can increase the time it takes to compile a pattern.
If the JIT isn't available or if JIT compilation returns an error, then a debug message with the error will be emitted and the regex will otherwise silently fall back to non-JIT matching.
This is disabled by default, and always overrides jit
.
Trait Implementations
impl Clone for RegexBuilder
[src]
impl Clone for RegexBuilder
fn clone(&self) -> RegexBuilder
[src]
fn clone(&self) -> RegexBuilder
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for RegexBuilder
[src]
impl Debug for RegexBuilder
Auto Trait Implementations
impl Send for RegexBuilder
impl Send for RegexBuilder
impl Sync for RegexBuilder
impl Sync for RegexBuilder