Struct regex_syntax::CharClass
[-] [+]
[src]
pub struct CharClass {
// some fields omitted
}A character class.
A character class has a canonical format that the parser guarantees. Its canonical format is defined by the following invariants:
- Given any Unicode scalar value, it is matched by at most one character range in a canonical character class.
- Every adjacent character range is separated by at least one Unicode scalar value.
- Given any pair of character ranges
r1andr2, ifr1.end < r2.start, thenr1comes beforer2in a canonical character class.
In sum, any CharClass produced by this crate's parser is a sorted
sequence of non-overlapping ranges. This makes it possible to test whether
a character is matched by a class with a binary search.
Additionally, a character class may be marked case insensitive. If it's case insensitive, then:
- Simple case folding has been applied to all ranges.
- Simple case folding must be applied to a character before testing whether it matches the character class.
Methods
impl CharClass
fn matches(&self, c: char) -> bool
Returns true if c is matched by this character class.
If this character class is case insensitive, then simple case folding
is applied to c before checking for a match.
fn is_case_insensitive(&self) -> bool
Returns true if this character class should be matched case insensitively.
When true, simple case folding has already been applied to the
class.