pub struct SyntaxBehavior(/* private fields */);
Expand description
Defines the behaviour of regex operators.
Implementations§
Source§impl SyntaxBehavior
impl SyntaxBehavior
Sourcepub const SYNTAX_BEHAVIOR_CONTEXT_INDEP_REPEAT_OPS: Self
pub const SYNTAX_BEHAVIOR_CONTEXT_INDEP_REPEAT_OPS: Self
?, *, +, {n,m}
Sourcepub const SYNTAX_BEHAVIOR_CONTEXT_INVALID_REPEAT_OPS: Self
pub const SYNTAX_BEHAVIOR_CONTEXT_INVALID_REPEAT_OPS: Self
error or ignore
Sourcepub const SYNTAX_BEHAVIOR_ALLOW_UNMATCHED_CLOSE_SUBEXP: Self
pub const SYNTAX_BEHAVIOR_ALLOW_UNMATCHED_CLOSE_SUBEXP: Self
...)...
Sourcepub const SYNTAX_BEHAVIOR_ALLOW_INVALID_INTERVAL: Self
pub const SYNTAX_BEHAVIOR_ALLOW_INVALID_INTERVAL: Self
{???
Sourcepub const SYNTAX_BEHAVIOR_ALLOW_INTERVAL_LOW_ABBREV: Self
pub const SYNTAX_BEHAVIOR_ALLOW_INTERVAL_LOW_ABBREV: Self
{,n} => {0,n}
Sourcepub const SYNTAX_BEHAVIOR_STRICT_CHECK_BACKREF: Self
pub const SYNTAX_BEHAVIOR_STRICT_CHECK_BACKREF: Self
/(\1)/,/\1()/ ..
Sourcepub const SYNTAX_BEHAVIOR_DIFFERENT_LEN_ALT_LOOK_BEHIND: Self
pub const SYNTAX_BEHAVIOR_DIFFERENT_LEN_ALT_LOOK_BEHIND: Self
(?<=a|bc)
Sourcepub const SYNTAX_BEHAVIOR_CAPTURE_ONLY_NAMED_GROUP: Self
pub const SYNTAX_BEHAVIOR_CAPTURE_ONLY_NAMED_GROUP: Self
See Oniguruma documenation
Sourcepub const SYNTAX_BEHAVIOR_ALLOW_MULTIPLEX_DEFINITION_NAME: Self
pub const SYNTAX_BEHAVIOR_ALLOW_MULTIPLEX_DEFINITION_NAME: Self
(?<x>)(?<x>)
Sourcepub const SYNTAX_BEHAVIOR_FIXED_INTERVAL_IS_GREEDY_ONLY: Self
pub const SYNTAX_BEHAVIOR_FIXED_INTERVAL_IS_GREEDY_ONLY: Self
a{n}?=(?:a{n})?
Sourcepub const SYNTAX_BEHAVIOR_NOT_NEWLINE_IN_NEGATIVE_CC: Self
pub const SYNTAX_BEHAVIOR_NOT_NEWLINE_IN_NEGATIVE_CC: Self
[^...]
Sourcepub const SYNTAX_BEHAVIOR_BACKSLASH_ESCAPE_IN_CC: Self
pub const SYNTAX_BEHAVIOR_BACKSLASH_ESCAPE_IN_CC: Self
[..\w..] etc..
Sourcepub const SYNTAX_BEHAVIOR_ALLOW_DOUBLE_RANGE_OP_IN_CC: Self
pub const SYNTAX_BEHAVIOR_ALLOW_DOUBLE_RANGE_OP_IN_CC: Self
[0-9-a]=[0-9\-a]
Sourcepub const SYNTAX_BEHAVIOR_WARN_CC_OP_NOT_ESCAPED: Self
pub const SYNTAX_BEHAVIOR_WARN_CC_OP_NOT_ESCAPED: Self
[,-,]
Sourcepub const SYNTAX_BEHAVIOR_WARN_REDUNDANT_NESTED_REPEAT: Self
pub const SYNTAX_BEHAVIOR_WARN_REDUNDANT_NESTED_REPEAT: Self
(?:a*)+
Source§impl SyntaxBehavior
impl SyntaxBehavior
Sourcepub const fn empty() -> Self
pub const fn empty() -> Self
Get a flags value with all bits unset.
Examples found in repository?
3fn main() {
4 let mut syntax = Syntax::default().clone();
5
6 syntax.set_operators(SyntaxOperator::SYNTAX_OPERATOR_VARIABLE_META_CHARACTERS);
7 syntax.set_behavior(SyntaxBehavior::empty());
8 syntax.set_options(RegexOptions::REGEX_OPTION_MULTILINE);
9
10 syntax.set_meta_char(MetaCharType::META_CHAR_ESCAPE, MetaChar::Character('\\'));
11 syntax.set_meta_char(MetaCharType::META_CHAR_ANYCHAR, MetaChar::Character('_'));
12 syntax.set_meta_char(MetaCharType::META_CHAR_ANYTIME, MetaChar::Ineffective);
13 syntax.set_meta_char(
14 MetaCharType::META_CHAR_ZERO_OR_ONE_TIME,
15 MetaChar::Ineffective,
16 );
17 syntax.set_meta_char(
18 MetaCharType::META_CHAR_ONE_OR_MORE_TIME,
19 MetaChar::Ineffective,
20 );
21 syntax.set_meta_char(
22 MetaCharType::META_CHAR_ANYCHAR_ANYTIME,
23 MetaChar::Character('%'),
24 );
25
26 let reg =
27 Regex::with_options("\\_%\\\\__zz", RegexOptions::REGEX_OPTION_NONE, &syntax).unwrap();
28
29 match reg.captures("a_abcabcabc\\ppzz") {
30 Some(caps) => {
31 println!("match at {}", caps.offset());
32 for (i, cap) in caps.iter_pos().enumerate() {
33 match cap {
34 Some(pos) => println!("{}: {:?}", i, pos),
35 None => println!("{}: did not capture", i),
36 }
37 }
38 }
39 None => println!("search fail"),
40 }
41}
Sourcepub const fn bits(&self) -> OnigSyntaxBehavior
pub const fn bits(&self) -> OnigSyntaxBehavior
Get the underlying bits value.
The returned value is exactly the bits set in this flags value.
Sourcepub const fn from_bits(bits: OnigSyntaxBehavior) -> Option<Self>
pub const fn from_bits(bits: OnigSyntaxBehavior) -> Option<Self>
Convert from a bits value.
This method will return None
if any unknown bits are set.
Sourcepub const fn from_bits_truncate(bits: OnigSyntaxBehavior) -> Self
pub const fn from_bits_truncate(bits: OnigSyntaxBehavior) -> Self
Convert from a bits value, unsetting any unknown bits.
Sourcepub const fn from_bits_retain(bits: OnigSyntaxBehavior) -> Self
pub const fn from_bits_retain(bits: OnigSyntaxBehavior) -> Self
Convert from a bits value exactly.
Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Get a flags value with the bits of a flag with the given name set.
This method will return None
if name
is empty or doesn’t
correspond to any named flag.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Whether any set bits in a source flags value are also set in a target flags value.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Whether all set bits in a source flags value are also set in a target flags value.
Sourcepub fn remove(&mut self, other: Self)
pub fn remove(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
remove
won’t truncate other
, but the !
operator will.
Sourcepub fn toggle(&mut self, other: Self)
pub fn toggle(&mut self, other: Self)
The bitwise exclusive-or (^
) of the bits in two flags values.
Sourcepub fn set(&mut self, other: Self, value: bool)
pub fn set(&mut self, other: Self, value: bool)
Call insert
when value
is true
or remove
when value
is false
.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
The bitwise and (&
) of the bits in two flags values.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
The bitwise or (|
) of the bits in two flags values.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
The bitwise exclusive-or (^
) of the bits in two flags values.
Sourcepub const fn complement(self) -> Self
pub const fn complement(self) -> Self
The bitwise negation (!
) of the bits in a flags value, truncating the result.
Source§impl SyntaxBehavior
impl SyntaxBehavior
Sourcepub const fn iter(&self) -> Iter<SyntaxBehavior>
pub const fn iter(&self) -> Iter<SyntaxBehavior>
Yield a set of contained flags values.
Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.
Sourcepub const fn iter_names(&self) -> IterNames<SyntaxBehavior>
pub const fn iter_names(&self) -> IterNames<SyntaxBehavior>
Yield a set of contained named flags values.
This method is like iter
, except only yields bits in contained named flags.
Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
Trait Implementations§
Source§impl Binary for SyntaxBehavior
impl Binary for SyntaxBehavior
Source§impl BitAnd for SyntaxBehavior
impl BitAnd for SyntaxBehavior
Source§impl BitAndAssign for SyntaxBehavior
impl BitAndAssign for SyntaxBehavior
Source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
The bitwise and (&
) of the bits in two flags values.
Source§impl BitOr for SyntaxBehavior
impl BitOr for SyntaxBehavior
Source§fn bitor(self, other: SyntaxBehavior) -> Self
fn bitor(self, other: SyntaxBehavior) -> Self
The bitwise or (|
) of the bits in two flags values.
Source§type Output = SyntaxBehavior
type Output = SyntaxBehavior
|
operator.Source§impl BitOrAssign for SyntaxBehavior
impl BitOrAssign for SyntaxBehavior
Source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
The bitwise or (|
) of the bits in two flags values.
Source§impl BitXor for SyntaxBehavior
impl BitXor for SyntaxBehavior
Source§impl BitXorAssign for SyntaxBehavior
impl BitXorAssign for SyntaxBehavior
Source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
The bitwise exclusive-or (^
) of the bits in two flags values.
Source§impl Clone for SyntaxBehavior
impl Clone for SyntaxBehavior
Source§fn clone(&self) -> SyntaxBehavior
fn clone(&self) -> SyntaxBehavior
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SyntaxBehavior
impl Debug for SyntaxBehavior
Source§impl Extend<SyntaxBehavior> for SyntaxBehavior
impl Extend<SyntaxBehavior> for SyntaxBehavior
Source§fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
The bitwise or (|
) of the bits in each flags value.
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl Flags for SyntaxBehavior
impl Flags for SyntaxBehavior
Source§const FLAGS: &'static [Flag<SyntaxBehavior>]
const FLAGS: &'static [Flag<SyntaxBehavior>]
Source§fn bits(&self) -> OnigSyntaxBehavior
fn bits(&self) -> OnigSyntaxBehavior
Source§fn from_bits_retain(bits: OnigSyntaxBehavior) -> SyntaxBehavior
fn from_bits_retain(bits: OnigSyntaxBehavior) -> SyntaxBehavior
Source§fn contains_unknown_bits(&self) -> bool
fn contains_unknown_bits(&self) -> bool
true
if any unknown bits are set.Source§fn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
Source§fn from_name(name: &str) -> Option<Self>
fn from_name(name: &str) -> Option<Self>
Source§fn iter_names(&self) -> IterNames<Self>
fn iter_names(&self) -> IterNames<Self>
Source§fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn contains(&self, other: Self) -> boolwhere
Self: Sized,
fn contains(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn insert(&mut self, other: Self)where
Self: Sized,
fn insert(&mut self, other: Self)where
Self: Sized,
|
) of the bits in two flags values.Source§fn remove(&mut self, other: Self)where
Self: Sized,
fn remove(&mut self, other: Self)where
Self: Sized,
&!
). Read moreSource§fn toggle(&mut self, other: Self)where
Self: Sized,
fn toggle(&mut self, other: Self)where
Self: Sized,
^
) of the bits in two flags values.Source§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
&
) of the bits in two flags values.Source§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
&!
). Read moreSource§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
^
) of the bits in two flags values.Source§fn complement(self) -> Self
fn complement(self) -> Self
!
) of the bits in a flags value, truncating the result.Source§impl FromIterator<SyntaxBehavior> for SyntaxBehavior
impl FromIterator<SyntaxBehavior> for SyntaxBehavior
Source§fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
The bitwise or (|
) of the bits in each flags value.
Source§impl Hash for SyntaxBehavior
impl Hash for SyntaxBehavior
Source§impl IntoIterator for SyntaxBehavior
impl IntoIterator for SyntaxBehavior
Source§impl LowerHex for SyntaxBehavior
impl LowerHex for SyntaxBehavior
Source§impl Not for SyntaxBehavior
impl Not for SyntaxBehavior
Source§impl Octal for SyntaxBehavior
impl Octal for SyntaxBehavior
Source§impl Ord for SyntaxBehavior
impl Ord for SyntaxBehavior
Source§fn cmp(&self, other: &SyntaxBehavior) -> Ordering
fn cmp(&self, other: &SyntaxBehavior) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for SyntaxBehavior
impl PartialEq for SyntaxBehavior
Source§impl PartialOrd for SyntaxBehavior
impl PartialOrd for SyntaxBehavior
Source§impl PublicFlags for SyntaxBehavior
impl PublicFlags for SyntaxBehavior
Source§impl Sub for SyntaxBehavior
impl Sub for SyntaxBehavior
Source§fn sub(self, other: Self) -> Self
fn sub(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
Source§type Output = SyntaxBehavior
type Output = SyntaxBehavior
-
operator.Source§impl SubAssign for SyntaxBehavior
impl SubAssign for SyntaxBehavior
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.