Look in regex_syntax::hir - Rust (original) (raw)
pub enum Look {
Show 18 variants Start = 1,
End = 2,
StartLF = 4,
EndLF = 8,
StartCRLF = 16,
EndCRLF = 32,
WordAscii = 64,
WordAsciiNegate = 128,
WordUnicode = 256,
WordUnicodeNegate = 512,
WordStartAscii = 1_024,
WordEndAscii = 2_048,
WordStartUnicode = 4_096,
WordEndUnicode = 8_192,
WordStartHalfAscii = 16_384,
WordEndHalfAscii = 32_768,
WordStartHalfUnicode = 65_536,
WordEndHalfUnicode = 131_072,
}
Expand description
The high-level intermediate representation for a look-around assertion.
An assertion match is always zero-length. Also called an “empty match.”
Match the beginning of text. Specifically, this matches at the starting position of the input.
Match the end of text. Specifically, this matches at the ending position of the input.
Match the beginning of a line or the beginning of text. Specifically, this matches at the starting position of the input, or at the position immediately following a \n
character.
Match the end of a line or the end of text. Specifically, this matches at the end position of the input, or at the position immediately preceding a \n
character.
Match the beginning of a line or the beginning of text. Specifically, this matches at the starting position of the input, or at the position immediately following either a \r
or \n
character, but never after a \r
when a \n
follows.
Match the end of a line or the end of text. Specifically, this matches at the end position of the input, or at the position immediately preceding a \r
or \n
character, but never before a \n
when a \r
precedes it.
Match an ASCII-only word boundary. That is, this matches a position where the left adjacent character and right adjacent character correspond to a word and non-word or a non-word and word character.
Match an ASCII-only negation of a word boundary.
Match a Unicode-aware word boundary. That is, this matches a position where the left adjacent character and right adjacent character correspond to a word and non-word or a non-word and word character.
Match a Unicode-aware negation of a word boundary.
Match the start of an ASCII-only word boundary. That is, this matches a position at either the beginning of the haystack or where the previous character is not a word character and the following character is a word character.
Match the end of an ASCII-only word boundary. That is, this matches a position at either the end of the haystack or where the previous character is a word character and the following character is not a word character.
Match the start of a Unicode word boundary. That is, this matches a position at either the beginning of the haystack or where the previous character is not a word character and the following character is a word character.
Match the end of a Unicode word boundary. That is, this matches a position at either the end of the haystack or where the previous character is a word character and the following character is not a word character.
Match the start half of an ASCII-only word boundary. That is, this matches a position at either the beginning of the haystack or where the previous character is not a word character.
Match the end half of an ASCII-only word boundary. That is, this matches a position at either the end of the haystack or where the following character is not a word character.
Match the start half of a Unicode word boundary. That is, this matches a position at either the beginning of the haystack or where the previous character is not a word character.
Match the end half of a Unicode word boundary. That is, this matches a position at either the end of the haystack or where the following character is not a word character.
Flip the look-around assertion to its equivalent for reverse searches. For example, StartLF
gets translated to EndLF
.
Some assertions, such as WordUnicode
, remain the same since they match the same positions regardless of the direction of the search.
Return the underlying representation of this look-around enumeration as an integer. Giving the return value to the Look::from_reprconstructor is guaranteed to return the same look-around variant that one started with within a semver compatible release of this crate.
Given the underlying representation of a Look
value, return the corresponding Look
value if the representation is valid. OtherwiseNone
is returned.
Returns a convenient single codepoint representation of this look-around assertion. Each assertion is guaranteed to be represented by a distinct character.
This is useful for succinctly representing a look-around assertion in human friendly but succinct output intended for a programmer working on regex internals.