pub enum Regex {
SingleCharacter {
value: u8,
},
Union {
options: Vec<Regex>,
},
Concat {
parts: Vec<Regex>,
},
Star {
repeated_pattern: Box<Regex>,
},
}
Expand description
A regular-expression pattern over raw bytes.
In practice, you won’t need to create instances of this type directly. Check out the Regex API and the high-level factory methods it offers.
Variants§
SingleCharacter
Only matches a single hardcoded byte.
Union
Matches each one of the specified patterns.
Concat
Matches a concatenation of the specified patterns.
Star
Matches a concatenation of zero or more repetitions of the specified pattern.
Implementations§
Source§impl Regex
impl Regex
Sourcepub fn single_char(value: char) -> Regex
pub fn single_char(value: char) -> Regex
Creates a pattern that only matches the specified character.
§Panics
If the character is not ASCII (cannot be represented by a single byte).
Sourcepub fn union(options: Vec<Regex>) -> Regex
pub fn union(options: Vec<Regex>) -> Regex
Creates a pattern that matches each of the specified patterns.
Sourcepub fn concat(parts: Vec<Regex>) -> Regex
pub fn concat(parts: Vec<Regex>) -> Regex
Creates a pattern that matches a concatenation of the specified patterns.
Sourcepub fn star_from(repeated_pattern: Regex) -> Regex
pub fn star_from(repeated_pattern: Regex) -> Regex
Creates a pattern that matches zero or more repetitions of the specified pattern.
Sourcepub fn plus_from(repeated_pattern: Regex) -> Regex
pub fn plus_from(repeated_pattern: Regex) -> Regex
Creates a pattern that matches one or more repetitions of the specified pattern.
Sourcepub fn white_space() -> Regex
pub fn white_space() -> Regex
Creates a pattern that matches a single white-space character.
Sourcepub fn constant_string(string: &str) -> Regex
pub fn constant_string(string: &str) -> Regex
Creates a pattern that matches a hard-coded sequence of characters.
Sourcepub fn character_range(start: char, end: char) -> Regex
pub fn character_range(start: char, end: char) -> Regex
Creates a pattern that matches any single character between the specified couple of characters (inclusive).